Display contents of variables during task execution

I would like to do display the results of variables during a playbook run. So for example, I might obtain the serial-number of a device from a task, register that into a variable, and then I want to display that to the screen somehow. What is the best way to display the value of a variable without using the “-v” option to ansible-playbook?

Thank you!

The debug module can do this

Brian Coca

Hi Brian,

Yes, I’d like to not use the “debug” option (-v) if possible, perhaps something like “printf” to format information to the user/screen.

Any thoughts/ideas?

Thank you!

Not the proper use, but pause module with info in prompt

Brian Coca

Hi Brian,

Interesting approach; but is there a way to just display the “prompt” without having the user enter anything back?

Thanks!

You can create a callback plugin that does this or maybe a patch to debug to add a ‘always print’ option is more suited to your needs.

Brian Coca

The solution here is to make the debug module always verbose in the core callbacks code, regardless of the specification of -v.

Somebody send me a patch and I’ll take it :slight_smile:

https://github.com/ansible/ansible/pull/3019​

Wicked.

Going to be merging part of the merge queue tonight so we’ll have this in super soon.