ansible/roles/ubuntu_base/tasks/users.yml

28 lines
792 B
YAML
Raw Normal View History

2018-05-08 19:09:24 +00:00
---
2022-11-26 08:52:41 +00:00
- name: Add users
2018-05-08 19:09:24 +00:00
user:
2022-11-26 09:47:37 +00:00
name: '{{ ubuntu_base_user.name }}'
comment: '{{ ubuntu_base_user.comment }}'
password: '{{ ubuntu_base_user.password }}'
groups: '{{ ubuntu_base_user.groups }}'
2022-11-26 08:52:41 +00:00
update_password: always
loop: '{{ users | default([]) }}'
2022-11-26 09:47:37 +00:00
loop_control:
loop_var: ubuntu_base_user
2018-05-08 19:09:24 +00:00
2022-11-26 08:52:41 +00:00
- name: Add ssh authorized_keys
ansible.posix.authorized_key:
2022-11-26 09:47:37 +00:00
user: '{{ ubuntu_base_user.name }}'
key: "{{ ubuntu_base_user.ssh_keys | join('\n') }}"
exclusive: true
2022-11-26 08:52:41 +00:00
loop: '{{ users | default([]) }}'
2022-11-26 09:47:37 +00:00
loop_control:
loop_var: ubuntu_base_user
2022-11-26 08:52:41 +00:00
- name: Add ssh authorized_keys to root user
ansible.posix.authorized_key:
2022-11-26 08:52:41 +00:00
user: root
key: "{{ users | default([]) | map(attribute='ssh_keys') | flatten | join('\n\
') }}"
exclusive: true