ansible/roles/create_users/tasks/main.yml
Jean-Marie Mineau a63a2a7bbb add shell
2021-01-29 23:51:13 +01:00

34 lines
802 B
YAML

---
- name: Generate user
user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
shell: "{{ item.shell }}"
loop: "{{ uservault_users }}"
- name: Set the passwords
replace:
path: /etc/shadow
regexp: '^{{ item.name }}:(.*?):(.*)'
replace: '{{ item.name }}:{{ item.password_hash }}:\2'
loop: "{{ uservault_users }}"
- name: Create .ssh file
file:
path: "/home/{{ item.name }}/.ssh"
state: directory
owner: "{{ item.name }}"
group: "{{ item.name }}"
loop: "{{ uservault_users }}"
- name: Add the key to the authorized_keys
lineinfile:
path: "/home/{{ item.name }}/.ssh/authorized_keys"
create: yes
mode: '0600'
owner: "{{ item.name }}"
group: "{{ item.name }}"
line: "{{ item.ssh_key }}"
loop: "{{ uservault_users }}"