Loading

Quipoin Menu

Learn • Practice • Grow

ansible / Troubleshooting
tutorial

Troubleshooting

Even well‑written playbooks can fail. Knowing how to troubleshoot Ansible runs saves time. This chapter covers common errors and techniques to debug.

Increase Verbosity

The -v (verbose) flag gives more output. Use multiple v’s for more detail:
ansible-playbook playbook.yml -vvv # shows SSH output
ansible-playbook playbook.yml -vvvv # extreme debugging

Check Mode and Diff

Run in check mode to see what would change without actually applying changes:
ansible-playbook playbook.yml --check --diff
--diff shows file differences for template and copy modules.

Debug Module

Print variable values or messages during execution:
- name: Print variable value
debug:
var: ansible_os_family

- name: Print custom message
debug:
msg: "The target OS is {{ ansible_os_family }}"

Syntax Check

Validate YAML syntax without executing:
ansible-playbook playbook.yml --syntax-check

Testing with a Single Host

Limit execution to one host to isolate issues:
ansible-playbook playbook.yml --limit web1

Common Errors and Fixes

  • Authentication failure: Check SSH keys, ansible_user, and --ask-pass or --ask-become-pass.
  • Module not found: Verify module name spelling; use ansible-doc -l to list.
  • YAML indentation: Use spaces, not tabs; run --syntax-check.
  • Permission denied: Add become: yes and ensure sudo rights.
  • Variable undefined: Use default() filter or ensure variable is defined in vars or inventory.

Logging

Enable logging to a file by setting in ansible.cfg or environment variable:
export ANSIBLE_LOG_PATH=~/ansible.log


Two Minute Drill
  • Use -vvv for verbose output, --check --diff for dry run.
  • Debug module prints variables and messages.
  • Validate syntax with --syntax-check.
  • Limit execution to a single host with --limit.
  • Common issues: authentication, permissions, indentation, undefined variables.

Need more clarification?

Drop us an email at career@quipoinfotech.com