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.


Ansible provides very handy module – debug_module, which is described in detail here:


Here is the nice way you can use the debug_module in order to print multiple variables values or all of them

Printing multiple ansible variables with debug purpose

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

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 !