Files

67 lines
2.1 KiB
YAML

---
- name: Create a new user with a password, set shell
remote_user: ansible
ansible.builtin.user:
name: "{{ human_admin_user }}"
groups: sshusers,sudo
password: "{{ user_passwd_hash }}"
shell: /bin/zsh
- name: Set authorized key taken from file
remote_user: ansible
ansible.posix.authorized_key:
user: "{{ human_admin_user }}"
state: present
key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
- name: Copy omz installation wrapper script to the target machine
remote_user: ansible
ansible.builtin.copy:
src: "{{ role_path }}/files/install_omz.sh"
dest: "/home/{{ human_admin_user }}/install_omz.sh"
owner: "{{ human_admin_user }}"
group: "{{ human_admin_user }}"
mode: u=rwx,g=r,o-rwx
# WARNING: UNPRIVILEGED USER (not ansible) COMMANDS
- name: Install oh my zsh
remote_user: "{{ human_admin_user }}"
ansible.builtin.command: "/home/{{ human_admin_user }}/install_omz.sh"
changed_when: true
vars:
- name: Configure oh my zsh, by pushing the config file
remote_user: ansible
ansible.builtin.copy:
src: "{{ role_path }}/files/.zshrc"
dest: "/home/{{ human_admin_user }}/.zshrc"
owner: "{{ human_admin_user }}"
group: "{{ human_admin_user }}"
mode: u=rw,g=r,o-rwx
- name: Configure vim, by pushing the config
remote_user: ansible
ansible.builtin.copy:
src: "{{ role_path }}/files/.vimrc"
dest: "/home/{{ human_admin_user }}/.vimrc"
owner: "{{ human_admin_user }}"
group: "{{ human_admin_user }}"
mode: u=rw,g=r,o-rwx
# WARNING: we've finished with the initial setup, drop ansible key
# Push regular user key
- name: Set authorized key taken from file
remote_user: ansible
ansible.posix.authorized_key:
user: "{{ human_admin_user }}"
state: absent
key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
- name: Set authorized key taken from file
remote_user: ansible
ansible.posix.authorized_key:
user: "{{ human_admin_user }}"
state: present
key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/max_regular_key.pub') }}"