Ansible "missing sudo password" even with passwordless sudo enabled
I have in my sudoers file
ALL ALL = (ALL) NOPASSWD: ALL
Which allows anyone to use sudo without entering a password. And I confirmed that I can sudo without a password when I ssh into the machine.
Yet when I attempt to run a playbook on it, I get an error "missing sudo password".
The command I'm using to run is
ansible-playbook -i inventory.yaml common_install.yaml --limit vpn.lan.example.com -vvv
I've run the same command, limiting it to a different host, that has the same sudo rule, and are both running Ubuntu 20.04, and it works on that. But won't work on this host.
Why won't it work?
Solution 1:
It is possible you have not populated the group_vars or host_vars directory(s) with the username and password values/files.
An example of a group_vars dir:
nodes.yml
ansible_port: 22
ansible_user: username
ansible_password: password
ansible_connection: ssh
ansible_become_pass: otherPassword
Note: the variables in the group_vars/host_vars directory(s) contain files with variables only do not include the vars:
keyword, or your other variables will be ignored.