2022-12-29 21:13:31 +00:00
|
|
|
# vim: ft=yaml.ansible
|
2024-03-01 20:30:18 +00:00
|
|
|
# code: language=ansible
|
2018-05-08 19:09:24 +00:00
|
|
|
---
|
2024-03-31 17:31:27 +00:00
|
|
|
- name: Add users
|
|
|
|
ansible.builtin.user:
|
2019-11-28 09:50:26 +00:00
|
|
|
name: "{{ item.name }}"
|
|
|
|
comment: "{{ item.comment }}"
|
2024-03-31 17:31:27 +00:00
|
|
|
password: "{{ item.password | default(omit) }}"
|
|
|
|
password_lock: "{{ item.password_lock }}"
|
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
|
2024-03-31 17:31:27 +00:00
|
|
|
loop: "{{ users }}"
|
|
|
|
no_log: true
|
2018-05-08 19:09:24 +00:00
|
|
|
|
2024-03-31 17:31:27 +00:00
|
|
|
- name: Add SSH keys to users
|
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
|
2024-03-31 17:31:27 +00:00
|
|
|
loop: "{{ users }}"
|
2018-06-23 12:44:00 +00:00
|
|
|
|
2024-03-31 17:31:27 +00:00
|
|
|
- name: Add SSH keys to Ansible user
|
2022-11-26 08:15:18 +00:00
|
|
|
ansible.posix.authorized_key:
|
2024-03-31 17:31:27 +00:00
|
|
|
user: ansible
|
|
|
|
key: "{{ users | map(attribute='ssh_keys') | flatten | join('\n') }}"
|
2022-11-15 18:57:17 +00:00
|
|
|
exclusive: true
|