FreeKB - Ansible ansible_python_interpreter variable
Ansible - ansible_python_interpreter variable

The gather_facts module must be set to true, which is the default setting of the gather_facts module. In other words, the gather_facts module must not be set to false.

Ansible uses version 2.x.x of Python to perform a number of different tasks and expects the Python command line tool to be located at /usr/bin/python. If a system only has both version 2.x.x and version 3.x.x of Python (e.g. /usr/bin/python3), the ansible_python_interpreter variable can be used to tell Ansible to use /usr/bin/python or /usr/bin/python3.

There are many different ways to define a variable - refer to Getting Started with Variables. For example, let's say you have the following playbook, which uses the vars module to define the ansible_python_interpreter variable.

- hosts: all
    ansible_python_interpreter: /usr/bin/python
    - name: Return Python interpreter
        msg: "Python interpreter = {{ ansible_python_interpreter }}"


Running this playbook should return the following.

TASK [debug]
ok: [] => {
    "msg: "Python interpreter = /usr/bin/python"


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 7c475 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |