Error: ansible requires a json module, none found!

Hi I searched google and only found https://groups.google.com/forum/#!topic/ansible-project/VvsonX7QrMk that deals with the similar problem.

My problem is:

I’m using RHEL6 as my main ansible station (ansible-1.1 from EPEL) and whenever I launch it against RHEL5 boxes I get:

$ ansible rhe5box.com -i my-serverlist -u root -m command -a “ls”

rhel5box.com | FAILED >> {
“failed”: true,
“msg”: “Error: ansible requires a json module, none found!”,
“parsed”: false
}
$ ssh root@rhel5box.com python -V
Python 2.4.3

Sounds like Ansible shouldn’t care for json on remote boxes but for some reason it does - something I’m missing?

Sure, you need to install simplejson on the RHEL 5 boxes.

you can get this from EPEL, or alternatively, use the ‘raw’ module in Ansible to SSH in at a low level and execute a yum install of the URL to the python-simplejson RPM.

Ansible requires python-simplejson being installed on EL boxes < 6. This is how modules can pass information back and forth (roughly).

You can bootstrap all your EL 5 boxes with this command:

ansible rhe5box.com -i my-serverlist -u root -m raw -a"yum install -y python-simplejson"

After that, ansible should work as advertised. This trick is hinted at in the requirements docs here: http://www.ansibleworks.com/docs/gettingstarted.html#requirements

But more detail can be seen here: http://www.ansibleworks.com/docs/modules.html#raw

A case could be made that this explicit issue should be talked about more clearly in the docs. Michael I know takes pull requests on Github. If not, filing an issue on Github might get you somewhere.

I had this problem too with RHEL. I think there is a RPM simplejson or so. Try that.

also sprach Dmitry Makovey <droopy4096@gmail.com> [2013.06.28.1746 +0200]:

Thanks Patrick. That explains the issue. This is a bit unfortunate since it does put some requirement for target system to be “compatible” with ansible whereas my impression was that ansible is “batteries included” kind of approach. However I’ll have to admit that single package shouldn’t be that much of an issue.

FYI found simplejson to be shipped directly from RHN:

yum info python-simplejson
Loaded plugins: cpacman_yum, rhnplugin, security
Available Packages
Name : python-simplejson
Arch : i386
Version : 2.0.9
Release : 8.el5
Size : 140 k
Repo : rhel-i386-server-5
Summary : Simple, fast, extensible JSON encoder/decoder for Python
License : MIT
Description: simplejson is a simple, fast, complete, correct and extensible JSON
: http://json.org encoder and decoder for Python 2.4+. It has no
: external dependencies.
:
: simplejson was formerly known as simple_json, but changed its name to
: comply with PEP 8 module naming guidelines.
:
: The encoder may be subclassed to provide serialization in any kind of
: situation, without any special support by the objects to be serialized
: (somewhat like pickle).
:
: The decoder can handle incoming JSON strings of any specified encoding
: (UTF-8 by default).

I think the `raw` module takes care of this IMHO. The ability to bootstrap
everything from ansible itself keeps it with the "batteries included" part.
I too have a bunch of RHEL 5 boxes I am managing with Ansible. That single
raw command got me up and running in less than 10 minutes. It took longer
to read and understand it than it took to make it actually work.

I encountered the same issue on my Ansible Host, when I try to run -m ping command to one of my linux server. After a detailed error information I got to know that ansible try to generate some files on client machine for that it requires “python-simplejson” available on the remote machine. After Installing the missing “python-simplejson” componant on remote machine I could able to run the command successfully.

-Jidnesh