Skip to content

Instantly share code, notes, and snippets.

@smurugap
Created June 6, 2019 21:26
Show Gist options
  • Save smurugap/614b85d0a7cb9a2709029a31d0e82951 to your computer and use it in GitHub Desktop.
Save smurugap/614b85d0a7cb9a2709029a31d0e82951 to your computer and use it in GitHub Desktop.
Debug ansible module failures
1) Set ANSIBLE_KEEP_REMOTE_FILES env before executing the playbook and run the playbook with -vvvv
for eg:
ANSIBLE_KEEP_REMOTE_FILES=1 ansible-playbook -i inventory/ playbooks/install_contrail.yml -vvvv
2) Look for PUT message in the logs corresponding to the task...
for eg:
<10.87.69.8> (0, 'sftp> put /root/.ansible/tmp/ansible-local-279680i0RrK/tmpXVp8uT /root/.ansible/tmp/ansible-tmp-1559855484.58-20011953793704/AnsiballZ_docker_service.py\n'
3) On the remote host cd to the directory and unzip the file
for eg:
cd /root/.ansible/tmp/ansible-tmp-1559855484.58-20011953793704/
python AnsiballZ_docker_service.py explode
4) debug_dir would have been created with __main__.py, args file and the dependent python modules
for eg:
root@5b12s10-node2:~/.ansible/tmp/ansible-tmp-1559855484.58-20011953793704# ls debug_dir/
__main__.py ansible args
5) You may add pdb inside the python modules or the __main__.py and run the module locally
for eg:
python AnsiballZ_docker_service.py execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment