When running a playbook, let's say the following warning is displayed.
[DEPRECATION WARNING]: Distribution fedora 34 on host server1.example.com 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/2.9/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.
As the warning suggests, deprecation warnings can be displayed in ansible.cfg. However, this is probably not the ideal solution.
deprecation_warnings=False
By default, The ansible_python_interpreter fact is set to auto_legacy. When set to auto_legacy, /usr/bin/python will be set as the ansible_python_interpreter instead of /usr/bin/python3. This warning can be suppressed by setting the ansible_python_interpreter fact to auto_legacy_silent, like this.
---
- hosts: all
vars:
ansible_python_interpreter: auto_legacy_silent
Or by setting interpreter_python in ansible.cfg, like this.
interpreter_python: auto_legacy_silent
Or to auto.
---
- hosts: all
vars:
ansible_python_interpreter: auto
Or to auto_silent.
---
- hosts: all
vars:
ansible_python_interpreter: auto_silent