Using host facts to diagnose failures

Some execution failures derive from the state of the target machine. The most common problem of this kind is the case where Ansible expects a file or variable to be present, but it's not.

Sometimes, it can be enough to print the machine facts to find the problem.

To do so, we need to create a simple playbook, called print_facts.yaml, which contains the following content:

---
- hosts: target_host
tasks:
- name: Display all variables/facts known for a host
debug:
var: hostvars[inventory_hostname]

This technique will give you a lot of information about the state of the target machine during Ansible execution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.161.116