Interview Prep/Ansible/Privilege Escalation and Python Interpreter Issues

`"msg": "/bin/sh: 1: /usr/bin/python: not found"` or `"The module failed to execute correctly, you probably need to set the interpreter."`

BeginnerTroubleshootingPrivilege Escalation and Python Interpreter Issues
Answer

Likely causes → Target has no Python, or only python3 at a different path.

Diagnose → ansible web01 -m raw -a 'which python3 python'.

Fix → Bootstrap Python with raw, or set ansible_python_interpreter=/usr/bin/python3.

- ansible.builtin.raw: test -e /usr/bin/python3 || (apt-get update && apt-get install -y python3)
  changed_when: false

Prevent → Bake Python in the image, or cloud-init it.

All Ansible questions Roadmap: Ansible

More on Privilege Escalation and Python Interpreter Issues