This blog contains some handy var dumping tips. For example, to dump the setup facts:
# Dump facts for domain example.com ansible -i inventory_file some_host -m setup
Another one is to dump all the vars for everything for some serious debugging. Save this to it’s own yml file.
--- - name: dump all hosts: all tasks: - name: Print some debug information vars: msg: | Module Variables ("vars"): -------------------------------- {{ vars | to_nice_json }} Environment Variables ("environment"): -------------------------------- {{ environment | to_nice_json }} GROUP NAMES Variables ("group_names"): -------------------------------- {{ group_names | to_nice_json }} GROUPS Variables ("groups"): -------------------------------- {{ groups | to_nice_json }} HOST Variables ("hostvars"): -------------------------------- {{ hostvars | to_nice_json }} debug: msg: "{{ msg.split('\n') }}" tags: debug_info
Beware – you can get a lot of output, but can be useful if you are trying to find out what vars are defined and which are overridden when you’ve got them set in groups, hosts and roles!