--- - hosts: all become: yes tasks: - name: Add ansible user to PiFrame user: name: ansible groups: - sudo shell: /bin/bash - name: Add ansible ssh key as authorized key authorized_key: user: ansible key: "{{ lookup('file', '/opt/ansible/ssh.key.pub') }}" - name: Setup ansible with sudoers access copy: dest: /etc/sudoers.d/ansible mode: '0600' owner: root group: root content: ansible ALL=(ALL) NOPASSWD:ALL