--- - name: Add user to sudoers ansible.builtin.copy: content: "{{ ansible_user }} ALL=(ALL:ALL) NOPASSWD:ALL" dest: "/etc/sudoers.d/{{ ansible_user }}_nopasswd" mode: "0440" - name: Add additional user SSH public keys ansible.posix.authorized_key: user: "{{ ansible_user }}" key: "{{ item }}" loop: "{{ ssh_authorized_keys }}" when: - ssh_authorized_keys is defined - ssh_authorized_keys is iterable - ssh_authorized_keys | length > 0