Ansible run ends up with MODULE FAILURE?

Solution 1:

This error also occurs when Python 2.x is not installed in /usr/bin/python. E.g. on Ubuntu 16.04 you have to install it:

sudo apt -y update && sudo apt install -y python-minimal

See also the ansible docs.

Solution 2:

Answer is, the user did no have sudo perms. Thanks everyone =)

Solution 3:

Disclaimer

In my case, it wasn't a sudo related problem. Posting for completion.

tl;dr

Don't use a virtualenv with two different versions of ansible (one in OS and the over in pip-virtualenv)

Explanation part

I had the same error with module "shell".

ansible -i ~/ansible-hosts example01 -mshell -a 'df -Ph' : MODULE FAILURE

ssh example01 'df -Ph' : no problem.

Problem

The version I had in my Debian (installed w/ aptitude) was 2.2.1.0 and the one in my Virtualenv (installed with pip from the Virtualenv) was 2.2.2.0.

Resolution

I uninstalled both and then re-installed the one in the Virtualenv.

hth