More local_action and ansible_python_interpreters

I hit a snag that occupied me for a good part of the day with how Ansible handles local actions and alternate paths to python interpreters. I saw that there has been some discussion over the months[1,2], but the resolution, if any, is unclear to me.

All of our servers are running a version of Red Hat that only ships with Python 2.4. A more modern Python (2.7) is in at an alternate location. When I tried to get a playbook using a local_action in the pre_task section I got a json could not be imported error. Even though I’ve created a localhost and 127.0.0.1 entry with a anisible_python_interpreter variable pointing to python 2.7, it still calls the default /usr/bin/python and that is 2.4. Since local_actions uses sh the environment variable settings (like PYTHONPATH) that I setup to get my python environment to where I need it are not passed along. So I understand why I’m getting this error. I don’t understand how to work around it.

How have other users been dealing with this? Any suggestions would be appreciated.

BTW: I’m running a version I pulled from github a few days ago. Installing simplejson for Python 2.4 in the default library path is not an option. (It’s out of my control otherwise the issue would have been solved already.)

[1] https://github.com/ansible/ansible/issues/1019
[2] https://github.com/ansible/ansible/issues/1225

So yes, this really should look up something that resembles localhost in inventory and see if it has any ansible_python_interpreter variables set.

I was trying to force the “Little Red Hen” scenario earlier by getting someone using it to submit a patch, somewhat unsuccessfully, as it wasn’t something I needed.

I believe the SSH port one is different than the ansible_python_interpreter one.

Patches would still be accepted.

I guess I’ll have to take a look at it when I get in tomorrow to see what I can do.