ansible/roles/create_users/tasks/main.yml

35 lines
802 B
YAML
Raw Normal View History

2021-01-29 22:27:04 +01:00
---
2021-01-29 23:49:19 +01:00
- name: Generate user
user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
2021-01-29 23:51:13 +01:00
shell: "{{ item.shell }}"
2021-01-29 23:49:19 +01:00
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 }}"
2021-01-29 22:27:04 +01:00
loop: "{{ uservault_users }}"