When working with Ansible , one of the “recipes” that I always keep handy is related to debugging variables. I find it particularly useful to have a comprehensive view of the variables associated with a host, defined at the “facts”, environment, group, and host levels.
By setting gather_facts: true
, we can access the variables through:
vars
environment
group_names
groups
hostvars
To print the variables in a readable format, the to_nice_json
filter can be used.