How I got this to talk to Python2.4 on CentOS 5.7

As I’m not super familiar with python, and I’m guessing others who want to try ansible might be in the same boat, just thought I’d document what it took to get my MacBook talking to a CentOS 5 box that is running Python 2.4. Throwing in all the errors so that hopefully folks find this in a Google search…

I kept getting this error when trying to do the initial ping:

import simplejson as json
ImportError: No module named simplejson

But I would shell into the machine, go into python and simplejson was there.

What took me some time to sort out was that running ‘which python’ wasn’t referencing the same version of python as the #!/usr/bin/env python in all of the ansible headers. ‘which python’ was returning ‘/usr/local/bin/python’ which was 2.6.4, so I thought I was good. But env was using /usr/bin/python which, I discovered by running /usr/bin/python -V returns “2.4.3”. Derp.

In this situation, if you just run easy_install simplejson, it was installing simplejson to the 2.6.4 version. Also running /usr/bin/python easy_install simplejson was throwing errors because easy_install was setup for the 2.6.4 version as well.

run ‘locate easy_install’ and you’ll probably find something like /usr/bin/easy_install-2.4. You have to specify this older version of easy_install if you’re adding modules to the older version of python like so: /usr/bin/python /usr/bin/easy_install-2.4 simplejson==2.0 (though I believe 2.1 will also work)

In my case, that alone wasn’t enough. I was still getting an error about finding a suitable distribution:

No local packages or download links found for simplejson==2.0
error: Could not find suitable distribution for Requirement.parse(‘simplejson==2.0’)

I had to also download a python module called ‘distribute’ by running:

curl -O http://python-distribute.org/distribute_setup.py

then running this using my 2.4 version of python:

/usr/bin/python distribute_setup.py

Now you’re ready to install simplejson.

/usr/bin/python /usr/bin/easy_install-2.4 simplejson==2.0 (again, 2.1 might work)

And finally, the ping works:

success >> {
“ping”: “pong”
}

Looking forward to getting started. Hope this helps others who are getting started.

Simplejson is available in EPEL

– Michael

Simplejson is available in EPEL

It looks like the version that's available in EPEL is for python 2.6.
But if you are on RHEL5 (as your managed node) and want to stick with
python 2.4 the python-simplejson package in the RHEL repos works just
fine. (At least it seems to for with, with the few simple tests I've
done with it.)

Romeo

Simplejson is available in EPEL

It looks like the version that’s available in EPEL is for python 2.6.
But if you are on RHEL5 (as your managed node) and want to stick with
python 2.4 the python-simplejson package in the RHEL repos works just
fine. (At least it seems to for with, with the few simple tests I’ve
done with it.)

Ansible’s controller code requires python 2.6, basing the decision of it being easily installable from EPEL.

We use newer Python stuff there.

Nodes only need 2.4

Right, just wanted to make it clear to folks that python-simplejson in
the RHEL5 repos works just fine on the managed nodes.