Interview Prep/Ansible/Privilege Escalation and Python Interpreter Issues

`Shared connection to web01 closed.` and the command output is truncated or garbled after `become`

IntermediateTroubleshootingPrivilege Escalation and Python Interpreter Issues
Answer

Likely causes → Interactive shell startup scripts, banners, or MOTD printing on non-interactive logins, or a custom login shell.

Diagnose → ssh web01 true | xxd | head to look for extra output; check /etc/profile.d, .bashrc, .bash_profile.

Fix → Remove output from shell profiles for the automation user (guard with an interactive check) and disable banners. Keep the user's shell as /bin/bash.

Prevent → Lint the base image for profile noise.

All Ansible questions Roadmap: Ansible

More on Privilege Escalation and Python Interpreter Issues