---
- name: Create SSH directory
become: true
file:
path: /home/{{ item.name }}/.ssh
state: directory
owner: "{{ item.name }}"
group: "{{ item.name }}"
mode: 0755
loop: "{{ _users_local }}"
- name: Update authorized keys
authorized_key:
user: "{{ item.name }}"
key: "{{ item.sshkeys | join('\n') }}"
state: present
exclusive: true
- name: Enforce ownership of authorized keys
path: /home/{{ item.name }}/.ssh/authorized_keys
state: touch
mode: 0444