REFACTOR: move removing unnecessary packages into base_system role

This commit is contained in:
2026-08-09 17:39:38 +04:00
parent bd3cb7bfd1
commit 269aaec21c
15 changed files with 500 additions and 40 deletions
@@ -0,0 +1,66 @@
---
- name: Create a new user with a password, set shell
remote_user: ansible
ansible.builtin.user:
name: max
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: max
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/max/install_omz.sh
owner: max
group: max
mode: u=rwx,g=r,o-rwx
# WARNING: UNPRIVILEGED USER (not ansible) COMMANDS
- name: Install oh my zsh
remote_user: max
become: false
ansible.builtin.command: /home/max/install_omz.sh
changed_when: true
- name: Configure oh my zsh, by pushing the config file
remote_user: ansible
ansible.builtin.copy:
src: "{{ role_path }}/files/.zshrc"
dest: /home/max/.zshrc
owner: max
group: max
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/max/.vimrc
owner: max
group: max
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: max
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: max
state: present
key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/max_regular_key.pub') }}"