CertGrid CertGrid
Troubleshooting·Ansible

Debugging Ansible Playbooks

Four techniques cover almost every Ansible problem: raise the verbosity, print the variable, assert what you assumed, and ask the inventory what it thinks. This works through all four, and finishes with the distinction between an error that `--syntax-check` catches and one it cannot.

Scale and Debugging Guide 39 of 45 Intermediate

Written against the versions above. Verbosity is cumulative: `-v` adds the full result of each task, `-vv` adds task and handler details, `-vvv` adds connection information including the exact ssh command, and `-vvvv` adds connection plugin debugging. `-vvv` is the level worth reaching for; `-vvvv` is rarely readable.

Both managed nodes. The assert step is more useful with two hosts to compare.
Server NameIP AddressOSRolesCPURAMHDD
ANS-CTL01192.168.0.36Ubuntu 26.04 LTSAnsible Control Node2 Core3 GB50 GB
ANS-A01192.168.0.37Ubuntu 26.04 LTSManaged Node (group: web)2 Core3 GB50 GB
ANS-B01192.168.0.38Ubuntu 26.04 LTSManaged Node (group: db)2 Core3 GB50 GB

Before you start

  1. The configuration this guide assumes

  2. The verbosity levels

  3. debug var versus debug msg

  4. assert fails loudly and early

  5. What does this host actually think

  6. A syntax error versus a runtime error

Official sources