You've been provided with a pre-configured Ansible environment. When you try to run a simple Ansible command, you encounter warnings about the Python interpreter. Your task is to resolve these warnings and ensure Ansible commands run without any interpreter-related issues.
To reproduce the warnings, run the following command in your terminal:
ansible all -m ping
You should see output similar to this:
[DEPRECATION WARNING]: Distribution ubuntu 22.04 on host localhost 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.10/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.
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
[DEPRECATION WARNING]: Distribution ubuntu 22.04 on host web1 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.10/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.
web1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
Your goal is to eliminate these warnings and ensure that Ansible uses Python 3.
Tasks
- Identify the Python interpreter warnings when running the Ansible command.
- Create an Ansible configuration file to specify the correct Python interpreter.
- Verify that the warnings have been resolved by running the command again.
Requirements
- All operations should be performed in the
/home/labex/project
directory.
- Create an Ansible configuration file named
ansible.cfg
in the /home/labex/project
directory.
- Use the appropriate configuration option to set the Python interpreter to
/usr/bin/python3
.
- The inventory file is already set up at
/etc/ansible/hosts
(provided in the initial setup).
Example
After correctly configuring Ansible, running the command should not produce any Python interpreter warnings. The output should look similar to this:
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
web1 | SUCCESS => {
"changed": false,
"ping": "pong"
}