Chapter #12: Ansible Troubleshooting
We all dream of a world where we never make mistakes or errors while running our Ansible playbooks.
In reality, such world doesn’t exist and so you need to have troubleshooting skills, so you are ready to deal with errors in your playbooks.
In this tutorial, you will learn how to enable logging in your playbooks. You will also learn a few other Ansible modules that can help you with troubleshooting. Finally, you will learn how to troubleshoot connectivity issues in Ansible.
Enable Ansible logging
By default, Ansible is not configured to log its output anywhere. You can however this behavior by setting the log_path configuration setting in your Ansible configuration file (ansible.cfg) to allow Ansible to log its output to a specific destination.
To demonstrate, let’s first set log_path in ansible.cfg:
This would enable Ansible playbooks and ad-hoc commands to log its output to a file named playbooks.log in your project directory.