Ansible warning in Fedora

Hi, all!

I am running Ansible on a host machine and I get the following warning:

TASK [Gathering Facts] *********************************************************
[DEPRECATION WARNING]: Distribution fedora 35 on host xxx.xxx.xxx.xxx should use
 /usr/bin/python3, but is using /usr/bin/python for backward compatibility with
 prior Ansible releases. A future Ansible release will default to using the 
discovered platform python for this host. See https://docs.ansible.com/ansible-
core/2.11/reference_appendices/interpreter_discovery.html for more information.
 This feature will be removed in version 2.12. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.

How can I change this from using python to python3?

Thanks!

Chances are high that python 3 already is installed.
You can check your installed version like this:
dnf list installed python*

/usr/bin/python

Most likely just is a Symlink to Python3

This is an isue of ansible while checking its dependencies.

So you would need to set the Interpreter in the ansible.cfg to /usr/bin/python3.
Ansible Config File
Python Interpreter

Best in /etc/ansible/ansible.cfg under point


[defaults]
interpreter_python = /usr/bin/python3

Edit
Removed distracting link

1 Like

Ansible is telling you it is still using the /usr/bin/python path and you really cannot easily change that.
On my system that is
$ ls -l /usr/bin/python
lrwxrwxrwx. 1 root root 9 Aug 31 08:36 /usr/bin/python → ./python3

As it tells you

Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg
1 Like

Setting the interpreter as you said in the .cfg file worked a charm! Thanks a lot :smile:

1 Like

I personally set this on the local copy of ansible.cfg and not on a global scale, or you can overwrite this per host in the inventory file.

[workrs]
host01 anible_interpreter_python=/usr/bin/python3
2 Likes

Great tip! Many thanks :smile:

1 Like