# Display contents of variables during task execution

**URL:** <https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841>\
**Category:** Ansible Project\
**Created:** [May 22, 2013, 12:04pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841 "2013-05-22T12:04:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jschulman](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jschulman](https://forum.ansible.com/u/jschulman)\
**Post date:** [May 22, 2013, 12:04pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/1 "2013-05-22T12:04:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [May 22, 2013, 12:08pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/2 "2013-05-22T12:08:46Z")

</div>

The debug module can do this

Brian Coca

---

<div class="post-metadata">

**Author:** ![jschulman](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jschulman](https://forum.ansible.com/u/jschulman)\
**Post date:** [May 22, 2013, 12:15pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/3 "2013-05-22T12:15:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [May 22, 2013, 12:16pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/4 "2013-05-22T12:16:57Z")

</div>

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

Brian Coca

---

<div class="post-metadata">

**Author:** ![jschulman](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jschulman](https://forum.ansible.com/u/jschulman)\
**Post date:** [May 22, 2013, 12:27pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/5 "2013-05-22T12:27:23Z")

</div>

Hi Brian,

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

Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [May 22, 2013, 12:29pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/6 "2013-05-22T12:29:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 22, 2013, 12:43pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/7 "2013-05-22T12:43:44Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 24, 2013, 10:48pm UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/8 "2013-05-24T22:48:05Z")

</div>

​[https://github.com/ansible/ansible/pull/3019​](https://github.com/ansible/ansible/pull/3019%E2%80%8B)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 25, 2013, 12:11am UTC](https://forum.ansible.com/t/display-contents-of-variables-during-task-execution/12841/9 "2013-05-25T00:11:48Z")

</div>

Wicked.

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