Ansible python interpreter

October 10, 2017

If you run into problems with the python which ansible uses to execute playbooks you can ensure that a specific python version gets used with the ansible_python_interpreter value set in the inventory file.

It is possible to hardcode the path to a custom python executable or what I prefer is to set the interpreter to the one that’s found first in the remote (or local) machine’s PATH. ansible_python_interpreter can be used to address that case as well if you have the env program installed in a reliable location. Here’s how you can do that in an inventory file:

ansible_python_interpreter="/usr/bin/env python"