Ansible – Launch Playbook with a specific version of Python

For example, there is an instance on which Python of the 2nd and 3rd versions is installed, but the default is 2nd, and in order not to change the default version and start the Playbook using Python3, you can use the following command:

python3 $(which ansible-playbook) -i localhost my-playbook.yaml

 

You can also specify the interpreter in the inventory file:

[localhost]
localhost ansible_connection=local ansible_python_interpreter=python3

 

Make sure Ansible module is installed for the correct version of Python

sudo pip3 install --user ansible

Tagged: Tags

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments