How to debug Ansible variables
Print all variables for all hosts from the command line:
$ ansible -i inventory/local -m debug -a "var=hostvars" all
Replace hostvars with any of the following to print:
- ansible_locals
- groups
- group_names
- environment
- vars
- ansible_sucks
Print all variables for all hosts from a playbook:
- hosts: all
tasks:
- debug:
var: hostvars[inventory_hostname]
# -vvv to debug !!!!
# verbosity: 4
Print all variables:
- name: print ansible_local
debug: var=ansible_local