--- - name: create .ssh directory become: yes file: path: "/home/{{ ssh_user }}/.ssh" state: directory - name: touch file become: yes file: path: "/home/{{ ssh_user }}/.ssh/authorized_keys" state: touch modification_time: preserve access_time: preserve - name: put pubkey become: yes lineinfile: path: "/home/{{ ssh_user }}/.ssh/authorized_keys" line: "{{ ssh_pubkey }}" state: present backup: yes