Interview Prep/Ansible/Privilege Escalation and Python Interpreter Issues

`FAILED! => {"msg": "The Python 2 yum module is needed for this module"}`

IntermediateTroubleshootingPrivilege Escalation and Python Interpreter Issues
Answer

Likely causes → Using the yum module on a host whose default Python is 3 but python3-dnf/yum bindings are missing, or on a modern host where dnf should be used.

Diagnose → rpm -q python3-dnf.

Fix → Use ansible.builtin.dnf (or package), and install python3-dnf.

Prevent → Use ansible.builtin.package for portability.

All Ansible questions Roadmap: Ansible

More on Privilege Escalation and Python Interpreter Issues