--- - 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 }}"