- name: Setup Ansible user and authorized keys gather_facts: false hosts: "{{ target }}" tasks: - name: Install Python if not already installed raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) changed_when: false failed_when: false - name: Install sudo package package: name: "sudo" state: "present" - name: setup ansible user user: name: "ansible" groups: "sudo" password: "{{ mypass | password_hash('sha512') }}" shell: /bin/bash - name: Setup Authorized keys authorized_key: user: "ansible" state: present key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"