--- - name: Setup Ansible User and Environment hosts: all remote_user: root become: yes tasks: - name: Install Python3 apt: name: python3 state: present - name: Install sudo apt: name: sudo state: present - name: Create ansible user user: name: ansible state: present create_home: yes shell: /bin/bash groups: ["users", "sudo"] password: "$6$F.AQzOBfVmeadQ3N$QYqzkqZ0qQiet0TlfYsWQelTJaBIiWjSVGuahrhCN5Ir7qX6goUjariH0YiD0muqd9c9r9xUWbZm3xExfK3Ri1" - name: Set ansible password command: echo "ansible:$(cat ./ansible.pass)" | chpasswd become: yes - name: Create .ssh directory file: path: "/home/ansible/.ssh" state: directory owner: ansible group: ansible mode: '0700' - name: Set Ansible authorized_keys ansible.posix.authorized_key: user: "ansible" key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIjMDDhinpnCPFUMERa/tLYymzRI8oJoAvXZnBH9wpA4 fake@gmail.com" state: present