--- - hosts: all tasks: - name: make direcotry file: path: "/home/pi/.ssh" state: directory - name: create empty file file: path: "/home/pi/.ssh/authorized_keys" state: touch - name: put pubkey lineinfile: path: "/home/pi/.ssh/authorized_keys" line: "{{ pubkey }}"