ansible_python_interpreter facts.d

Hi there.

On a few old/legacy systems I have installed python 2.6 in a nondefault location whereas the “default” (path) is an older version such as 2.4. In some cases I have legacy apps that may need the old version and I don’t want to affect their environment.

Setting ansible_python_interpreter to the python26 binary works well, however I also have a bunch of facts.d scripts which use python, unfortunately these pickup the 2.4 version. I was just wondering if there is a built in solution to handle this?

The current solution I came up with was to use the environment.PATH setting in the ansible playbook to add a path which contains the 26 python binary. This works with a caveat, however facts appear to be gathered before the PATH is set, so i need to regather facts after I set the environment.

The other solution I was thinking of is just maintaining a symbolic link to the correct python version which then I would hard code in the shebang for the python facts scripts.

Just wondering if anyone has a better solution or perhaps this might be a good enhancement request. Perhaps the ansible setup module could detect that the fact script is python and call it with the ansible_python_interpreter if it’s set?

Ansible does not handle the 'interpreter' for facts.d scripts, it just
executes them, so you should be able to control the 'python used' by
altering the shebang.