Categories

Category cover

Automation
155 posts

Category cover

Learning paths
119 posts

Category cover

CISO
22 posts

Category cover

Security
20 posts

Category cover

Notes
19 posts

Category cover

Personal Security
18 posts

Category cover

Infrastructure
12 posts

Category cover

OT/ICS
5 posts

Category cover

Books
3 posts

Category cover

UNetLab
3 posts

Category cover

Write-up
3 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Debug all variables with Ansible

Andrea Dainese
October 06, 2023
Post cover

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:

  • Module: vars
  • Environment: environment
  • Group names: group_names
  • Groups: groups
  • Hosts: hostvars

To print the variables in a readable format, the to_nice_json filter can be used.