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?

  • Check the logs on the server. – Michael Hampton Dec 12 '20 at 2:30
  • 1
    Add to your question the parsed sudo commands, the output of ansible -i inventory.yaml -m command -a "sudo --list" --limit vpn.lan.example.com sudo config can be non-trivial, loading various files and even from ldap if configured, not to mention being sure to check the correct user on the correct host. – John Mahowald Dec 12 '20 at 5:09
  • have you tried setting ansible_become_password as an emtpy string in the inventory file – Peter Jan 3 at 21:28

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:


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.