Last Updated: February 25, 2016
·
9.106K
· danielpetisme

Fixing Ansible Python 2.6 dependency on for (RHEL|CentOS) 5

These days I wanted to give Ansible a try. And the first barrier has been its installation. Ansible relies on Python 2.6My sandbox is a CentOs 5 one and the standard version of Python is 2.4.

So first has mentioned in the documentation, I have enabled the EPEL repositories and installed the required dependencies.

And that's where the problems started

Picture

Indeed on CentOs 5, YUM requires Python is 2.4. So you want just update you're version of Python updating the symnlink.

So the issue is how to use Python 2.6 (for Ansible ) and Python 2.4 at the same time?

Well, the answer is more a trick than a tip. You have to put BOTH versions into you path, and both must propose the python executable. BUT Python 2.6 must be ahead in the path.

For instance in my config I have

$ echo $PATH
/usr/local/bin:/bin:/usr/bin
$ which python
/usr/bin/python

So the trick is

$ ln -sf  /usr/bin/python26 /usr/local/bin/python

With that:

  • python 2.6 is in /usr/local/bin *which is before /usr/bin in the PATH
  • python 2.4 is in /usr/bin
  • And both are in the PATH

With such workaround I'm able to properly use Ansible and still have YUM working.

4 Responses
Add your response

Came across this same issue. Thanks for the trick(tip)!

over 1 year ago ·

Or you could just install ansible in a virtualenv.

over 1 year ago ·

After this nice workaround , did you face any other issues?

over 1 year ago ·

After the workaround, it worked like a charm.

over 1 year ago ·