What does "localhost | FAILED => Missing become password" mean? How do I get past it?

I have a Ubuntu 14.04 virtual machine set up in virtualbox and I am trying to follow these instructions.

https://serversforhackers.com/an-ansible-tutorial

When I get to the module section and try to install nginx with this command. with "local" being set to "localhost" in /etc/ansible/hosts

ansible local -s -m shell -a 'apt-get install nginx'

I get the following error:

localhost | FAILED => Missing become password

I have searched google for a way to get past this, but I do not understand what I am doing wrong.

This was a fresh install of the Server OS, and the only setup was done is in this tutorial.


Solution 1:

The problem is related to sudo. In /etc/ansible/ansible.cfg there is a commented out setting called ask_sudo_pass which needs to be uncommented out and set to Yes. Alternatively you can set the group the user belongs to to be able to use sudo without a password, but that's a security risk in my opinion.

Solution 2:

There was a bug introduced in Ansible 1.9 that may be the cause: ask_sudo_pass in ansible.cfg has no effect #10891