ansible/roles/adminuser/tasks/main.yml

28 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2021-02-26 10:07:57 -06:00
#!/usr/bin/env ansible-playbook
# vim:ft=ansible:
- name: assure admin user
2022-06-16 23:45:29 -05:00
ansible.builtin.user:
2021-02-26 10:07:57 -06:00
name: "{{ adminuser_name }}"
append: "{{ adminuser_groups_append }}"
groups: "{{ adminuser_groups + adminuser_groups_extra }}"
shell: "{{ adminuser_shell }}"
- name: assure admin user ssh key
2022-06-16 23:45:29 -05:00
ansible.builtin.user:
2021-02-26 10:07:57 -06:00
name: "{{ adminuser_name }}"
generate_ssh_key: yes
ssh_key_type: "{{ adminuser_ssh_key_type }}"
ssh_key_file: ".ssh/id_{{ adminuser_ssh_key_type }}"
when: adminuser_ssh_key
- name: assure admin user ssh authorized keys
authorized_key: user={{ adminuser_name }} key={{ item }}
loop: "{{ adminuser_ssh_authorized_keys }}"
- name: remove admin user ssh keys
authorized_key: state=absent user={{ adminuser_name }} key={{ item }}
loop: "{{ adminuser_ssh_unauthorized_keys }}"
- name: assure admin user pass
2022-06-16 23:45:29 -05:00
ansible.builtin.user: name={{ adminuser_name }} password={{ adminuser_password }}
2021-02-26 10:07:57 -06:00
when: adminuser_password is defined
- name: assure admin user sudo rule
2022-06-16 23:45:29 -05:00
ansible.builtin.lineinfile: path=/etc/sudoers line={{ adminuser_sudo_rule }}
2021-02-26 10:07:57 -06:00
when: adminuser_sudo