FreeKB - 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.

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
  vars:
    ansible_python_interpreter: /usr/bin/python
  tasks:
    - name: Return Python interpreter
      debug:
        msg: "Python interpreter = {{ ansible_python_interpreter }}"

 

Running this playbook should return the following.

TASK [debug]
ok: [server1.example.com] => {
    "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 2d931 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |