[ About | Licence | Contacts ]
Written by Oleksandr Gavenko (AKA gavenkoa), compiled on 2020-02-13 from rev d88d5d1a8cd9+.


Debugging Ansible

Pass -vvv to Ansible utilities:

ansible -vvv ...
ansible-playbook -vvv ...

To debug connection use -vvvv:

ansible -vvvv ...

To debug Python modules set ANSIBLE_KEEP_REMOTE_FILES to 1 (it causes Ansible to leave the exact copy of the Python scripts it executed on the target machine):


There is debugger keyword that triggers debugger, see Ansible Debugger

To activate debugger on task:

- name: Execute a command
  command: false
  debugger: on_failed

To activate debugger in ansible.cfg:

enable_task_debugger = True

To activate debugger via env var:

ANSIBLE_ENABLE_TASK_DEBUGGER=True ansible-playbook -i hosts site.yml

Use ansible-lint:

$ sudo apt install ansible-lint
$ ansible-lint site.yml
Network Debug and Troubleshooting Guide.
How to debug Ansible issues?

Bash completion

Provide bash-completion script for ansible commands.
As of Ansible 2.9 shell completion of the ansible command line utilities is available and provided through an optional dependency called argcomplete.