Debugging modules
-
The most basic way is to run
ansible
/ansible-playbook
with an increased verbosity level by adding-vvv
to the execution line. -
The most thorough way for the modules written in Python (Linux/Unix) is to run
ansible
/ansible-playbook
with an environment variableANSIBLE_KEEP_REMOTE_FILES
set to1
(on the control machine).
It causes Ansible to leave the exact copy of the Python scripts it executed (either successfully or not) on the target machine.
The path to the scripts is printed in the Ansible log and for regular tasks they are stored under the SSH user’s home directory: ~/.ansible/tmp/
.
The exact logic is embedded in the scripts and depends on each module. Some are using Python with standard or external libraries, some are calling external commands.
Debugging playbooks
-
Similarly to debugging modules increasing verbosity level with
-vvv
parameter causes more data to be printed to the Ansible log -
Since Ansible 2.1 a Playbook Debugger allows to debug interactively failed tasks: check, modify the data; re-run the task.
Debugging connections
- Adding
-vvvv
parameter to theansible
/ansible-playbook
call causes the log to include the debugging information for the connections.