28 lines
731 B
YAML
28 lines
731 B
YAML
# vim: ft=yaml.ansible
|
|
# code: language=ansible
|
|
---
|
|
- name: Add users
|
|
ansible.builtin.user:
|
|
name: "{{ item.name }}"
|
|
comment: "{{ item.comment }}"
|
|
password: "{{ item.password | default(omit) }}"
|
|
password_lock: "{{ item.password_lock }}"
|
|
groups: "{{ item.groups }}"
|
|
update_password: always
|
|
shell: /bin/bash
|
|
loop: "{{ users }}"
|
|
no_log: true
|
|
|
|
- name: Add SSH keys to users
|
|
ansible.posix.authorized_key:
|
|
user: "{{ item.name }}"
|
|
key: "{{ item.ssh_keys | join('\n') }}"
|
|
exclusive: true
|
|
loop: "{{ users }}"
|
|
|
|
- name: Add SSH keys to Ansible user
|
|
ansible.posix.authorized_key:
|
|
user: ansible
|
|
key: "{{ users | map(attribute='ssh_keys') | flatten | join('\n') }}"
|
|
exclusive: true
|