Interview Prep/Ansible/Privilege Escalation and Python Interpreter Issues

`Unable to encode the result: "AnsiballZ" ... SyntaxError: invalid syntax` when targeting an old CentOS 6 host

AdvancedTroubleshootingPrivilege Escalation and Python Interpreter Issues
Answer

Likely causes → Python on the target is too old for the Ansible version's modules (current ansible-core needs Python 3.8+ on targets; Python 2.7 support is gone).

Diagnose → ansible web01 -m raw -a 'python --version' and ansible --version.

Fix → Install a newer Python on the host, or use an older ansible-core supported for that target, or upgrade the OS.

Prevent → Track the target Python support matrix on every Ansible upgrade.

All Ansible questions Roadmap: Ansible

More on Privilege Escalation and Python Interpreter Issues