ansible/roles/ubuntu_base/tasks/users.yml
Sam A. 5bcba6fa59 QoL changes for *Vim users (#144)
Co-authored-by: Sam Al-Sapti <sam@sapti.me>
Reviewed-on: data.coop/ansible#144
2022-12-29 21:13:31 +00:00

24 lines
651 B
YAML

# vim: ft=yaml.ansible
---
- name: "Add users"
user:
name: "{{ item.name }}"
comment: "{{ item.comment }}"
password: "{{ item.password }}"
groups: "{{ item.groups }}"
update_password: "always"
loop: "{{ users | default([]) }}"
- name: "Add ssh authorized_keys"
ansible.posix.authorized_key:
user: "{{ item.name }}"
key: "{{ item.ssh_keys | join('\n') }}"
exclusive: true
loop: "{{ users | default([]) }}"
- name: "Add ssh authorized_keys to root user"
ansible.posix.authorized_key:
user: "root"
key: "{{ users | default([]) | map(attribute='ssh_keys') | flatten | join('\n') }}"
exclusive: true