28 lines
792 B
YAML
28 lines
792 B
YAML
---
|
|
- name: Add users
|
|
user:
|
|
name: '{{ ubuntu_base_user.name }}'
|
|
comment: '{{ ubuntu_base_user.comment }}'
|
|
password: '{{ ubuntu_base_user.password }}'
|
|
groups: '{{ ubuntu_base_user.groups }}'
|
|
update_password: always
|
|
loop: '{{ users | default([]) }}'
|
|
loop_control:
|
|
loop_var: ubuntu_base_user
|
|
|
|
- name: Add ssh authorized_keys
|
|
ansible.posix.authorized_key:
|
|
user: '{{ ubuntu_base_user.name }}'
|
|
key: "{{ ubuntu_base_user.ssh_keys | join('\n') }}"
|
|
exclusive: true
|
|
loop: '{{ users | default([]) }}'
|
|
loop_control:
|
|
loop_var: ubuntu_base_user
|
|
|
|
- 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
|