2022-12-29 21:13:31 +00:00
|
|
|
# vim: ft=yaml.ansible
|
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 }}"
|
2023-10-04 19:44:37 +00:00
|
|
|
update_password: always
|
|
|
|
shell: /bin/bash
|
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-26 08:15:18 +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-26 08:15:18 +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
|