# Debugging Ansible
## Interactively Debugging with Ansible's Python Version
Usually with: `/opt/ansible-2.9.17/bin/python` (adjusted for whichever version of Ansible you're using).
## Cleaner Output
For cleaner output when debugging Ansible playbooks, use
```code
[defaults]
...
stdout_callback = yaml
```
(`debug` and `json` are also available)
It takes output from looking like this:
```
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "/opt/ansible-2.9.17/local/lib/python2.7/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.\n from cryptography import x509\nTraceback (most recent call last):\n File \"<stdin>\", line 102, in <module>\n File \"<stdin>\", line 94, in _ansiballz_main\n File \"<stdin>\", line 40, in invoke_module\n File \"/usr/lib/python2.7/runpy.py\", line 176, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_locks_payload_jS02s_/ansible_locks_payload.zip/ansible/modules/locks.py\", line 311, in <module>\n File \"/tmp/ansible_locks_payload_jS02s_/ansible_locks_payload.zip/ansible/modules/_locks.py\", line 307, in main\n File \"/tmp/ansible_locks_payload_jS02s_/ansible_locks_payload.zip/ansible/modules/_locks.py\", line 284, in run_module\n File \"/tmp/ansible_locks_payload_jS02s_/ansible_locks_payload.zip/ansible/modules/_locks.py\", line 193, in get_current_user\n File \"/tmp/ansible_locks_payload_jS02s_/ansible_locks_payload.zip/ansible/modules/_locks.py\", line 188, in get_current_user_with_api\nKeyError: 'user'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
```
to this:
```
fatal: [localhost]: FAILED! => changed=false
module_stderr: |-
/opt/ansible-2.9.17/local/lib/python2.7/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography import x509
Traceback (most recent call last):
File "<stdin>", line 102, in <module>
File "<stdin>", line 94, in _ansiballz_main
File "<stdin>", line 40, in invoke_module
File "/usr/lib/python2.7/runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/tmp/ansible_locks_payload_ClUBXh/ansible_locks_payload.zip/ansible/modules/locks.py", line 311, in <module>
File "/tmp/ansible_locks_payload_ClUBXh/ansible_locks_payload.zip/ansible/modules/locks.py", line 307, in main
File "/tmp/ansible_locks_payload_ClUBXh/ansible_locks_payload.zip/ansible/modules/locks.py", line 284, in run_module
File "/tmp/ansible_locks_payload_ClUBXh/ansible_locks_payload.zip/ansible/modules/locks.py", line 193, in get_current_user
File "/tmp/ansible_locks_payload_ClUBXh/ansible_locks_payload.zip/ansible/modules/locks.py", line 188, in get_current_user_with_api
KeyError: 'user'
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
```
Source:: https://stackoverflow.com/questions/37171966/clean-error-output-in-ansible-playbook