ansible troubleshooting - ghdrako/doc_snipets GitHub Wiki

  • Use the debug module: When writing your playbooks, use Ansible’s debug module to display variables, messages, or task output, helping you identify issues in your code.
---
- hosts: localhost
  gather_facts: yes
  tasks:
    - name: Print all the facts
      debug:
        var: ansible_facts

Above playbook uses the debug module to output the contents of the ansible_facts variable

  • Increase verbosity levels Ansible hides quite a lot of information when you run ansible-playbook; you can add the -v, -vv, or -vvv options to increase the verbosity of the output, providing more insight into what’s happening during execution.

  • Check your YAML syntax validate your YAML files with a linter or online validator to catch any formatting or syntax errors.

  • Review the failed and skipped task summaries: Examine the failed and skipped task summaries at the end of a playbook run to identify tasks that did not execute as expected; Ansible may not completely stop execution on a failed task, so ensure that you pay attention to your playbook runs as you may have problems and not immediately realize it.

  • Verify file and directory permissions: Ensure that the appropriate file and directory permissions are set for your Ansible files and target hosts, allowing the required access for execution.