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