[Ansible] – How to upgrade for python3?

Following the installation steps.
$ pip3 install --upgrade setuptools pip
$ pip install --user ansible
After the python3 be already installed you may will be still checking the following warning which means that it still using the version 2 to execute your playbooks.
[WARNING]: Platform linux on host kind-test-local is using the discovered
3362Python interpreter at /usr/bin/python, but future installation of another
3363Python interpreter could change this. See https://docs.ansible.com/ansible/2.8/
3364reference_appendices/interpreter_discovery.html for more information.
So, the solution is to use the `ansible_python_interpreter` attribute as global var in the hosts of your inventory as the following example.
[test]
ansible_host=127.0.0.1 ansible_connection=local

[all:vars]
ansible_python_interpreter=/usr/bin/python3
Note that without defining the interpreter it will still using version 2 (`/usr/bin/python`).
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s