ansible/roles/users/tasks/main.yml

21 lines
570 B
YAML
Raw Normal View History

2022-07-19 11:44:55 +02:00
---
- name: Create users
user:
name: "{{ item.key }}"
groups: "{{ item.value | default('') }}"
shell: "{{ user_dict[item.key].shell | default('/bin/bash') }}"
password: "{{ user_dict[item.key].password_hash }}"
update_password: always
state: present
loop: "{{ users | dict2items }}"
- name: Add SSH key to users
authorized_key:
key: "{{ user_dict[item.key].ssh_keys | join('\n') }}"
user: "{{ item.key }}"
exclusive: no
2022-07-21 15:19:24 +02:00
path: "/etc/ssh/authorized_keys/{{ item.key }}"
2022-07-19 11:44:55 +02:00
state: present
loop: "{{ users | dict2items }}"