2018-05-08 19:09:24 +00:00
|
|
|
---
|
2018-05-08 19:31:12 +00:00
|
|
|
- name: "Add users"
|
2018-05-08 19:09:24 +00:00
|
|
|
user:
|
2019-11-28 09:50:26 +00:00
|
|
|
name: "{{ item.name }}"
|
|
|
|
comment: "{{ item.comment }}"
|
|
|
|
password: "{{ item.password }}"
|
2022-11-15 18:57:17 +00:00
|
|
|
groups: "{{ item.groups }}"
|
|
|
|
update_password: "always"
|
2019-11-28 09:50:26 +00:00
|
|
|
loop: "{{ users | default([]) }}"
|
2018-05-08 19:09:24 +00:00
|
|
|
|
|
|
|
- name: "Add ssh authorized_keys"
|
2022-11-25 23:11:16 +00:00
|
|
|
ansible.posix.authorized_key:
|
2022-11-15 18:57:17 +00:00
|
|
|
user: "{{ item.name }}"
|
2022-11-15 19:28:34 +00:00
|
|
|
key: "{{ item.ssh_keys | join('\n') }}"
|
2022-11-15 18:57:17 +00:00
|
|
|
exclusive: true
|
|
|
|
loop: "{{ users | default([]) }}"
|
2018-06-23 12:44:00 +00:00
|
|
|
|
|
|
|
- name: "Add ssh authorized_keys to root user"
|
2022-11-25 23:11:16 +00:00
|
|
|
ansible.posix.authorized_key:
|
2018-06-23 12:44:00 +00:00
|
|
|
user: "root"
|
2022-11-16 15:24:22 +00:00
|
|
|
key: "{{ users | default([]) | map(attribute='ssh_keys') | flatten | join('\n') }}"
|
2022-11-15 18:57:17 +00:00
|
|
|
exclusive: true
|