Your new hosts file will look like this:
[webserver] web-01 ansible_ssh_host=192.168.0.11 ansible_ssh_user=USERNAME ansible_ssh_private_key_file=/secure/mykey
But please also create sudo: True in your player:
--- - hosts: webserver sudo: True remote_user: USERNAME gather_facts: True
The important thing is that your sudo user must be less than a password in order to ensure that you have to edit the sudoer file. If you are using CentOS, edit the file / etc / sudoers and add the following line
USERNAME ALL=(ALL) NOPASSWD: ALL
add this line after the last line that says
If you are using Ubuntu, use the visudo command, find and edit the following line:
source share