Ansible Debug Print All Variables

Published on Author gryzli

I have written a post about how to debug playbooks by dumping all variables in file (on remote server) by using Ansible template file. Here is some faster and more convenient way to print multiple variables or all with debug purpose inside a playbook.

Here are some handy commands for quick dumping of a given variable, multiple variables, or all variables. 

Dump all variables/facts for a given host (without invoking a playbook)

1) Based on inventory file 

2) Without inventory file

Here is how you can dump the facts, without even having an inventory file: 

(Don’t forget the “,” (comma) in the end of the hostname/ip)


Printing multiple Ansible variables with debug purpose (inside a playbook)

First you need to define your debug task , which I called debug_info in my case:

I have used some nice technique (I found out there) for printing multi-line message inside debug statement:


In order to get only the debug information (without executing any other tasks inside the playbook), you could limit the task executing by providing “–tags ‘debug_info’ ” to ansible-playbook command.

So after executing command:

ansible-playbook --tags "debug_info" -i hosts/ test.yml

I’m getting something like this:

Output from running ansible debug_module for printing variables
Ansible multiline variable debug


Printing all Ansible variables with debug purpose (inside a playbook)

Now if we want to print all internal variables, we could use the following yaml:


Another good way is to use something like that:


Executing this task is going to dump all your variables.

Cheers !


If you are interested in Ansible performance tunning as well, take a look here: 

Tuning Ansible For Maximum Performance