# ansible\_python\_interpreter facts.d

**URL:** <https://forum.ansible.com/t/ansible-python-interpreter-facts-d/30321>\
**Category:** Ansible Project\
**Created:** [May 14, 2019, 12:25am UTC](https://forum.ansible.com/t/ansible-python-interpreter-facts-d/30321 "2019-05-14T00:25:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_E](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@Adam\_E](https://forum.ansible.com/u/Adam_E)\
**Post date:** [May 14, 2019, 12:25am UTC](https://forum.ansible.com/t/ansible-python-interpreter-facts-d/30321/1 "2019-05-14T00:25:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 14, 2019, 1:54pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-facts-d/30321/2 "2019-05-14T13:54:38Z")

</div>

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.
