--- - name: Prepare servers for Ansible hosts: all gather_facts: false tasks: - name: Create ansible user user: name: ansible groups: wheel - name: Setup public key for Ansible user authorized_key: user: ansible state: present key: "{{ lookup('file','/home/ansible/.ssh/id_rsa.pub') }}" - name: Create ansible sudoers file file: path: /etc/sudoers.d/ansible state: touch - name: Put info into file blockinfile: path: /etc/sudoers.d/ansible block: | # Set ansible user sudo without password %ansible ALL=(ALL) NOPASSWD: ALL