# A problem with using the virt module output as a registered variable for looping

**URL:** <https://forum.ansible.com/t/a-problem-with-using-the-virt-module-output-as-a-registered-variable-for-looping/15569>\
**Category:** Ansible Project\
**Created:** [June 28, 2014, 12:47am UTC](https://forum.ansible.com/t/a-problem-with-using-the-virt-module-output-as-a-registered-variable-for-looping/15569 "2014-06-28T00:47:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [June 28, 2014, 12:47am UTC](https://forum.ansible.com/t/a-problem-with-using-the-virt-module-output-as-a-registered-variable-for-looping/15569/1 "2014-06-28T00:47:35Z")

</div>

I have the following simple task include file:

---

<div class="post-metadata">

**Author:** ![Dustin\_C\_Hatch](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@Dustin\_C\_Hatch](https://forum.ansible.com/u/Dustin_C_Hatch)\
**Post date:** [June 28, 2014, 1:07am UTC](https://forum.ansible.com/t/a-problem-with-using-the-virt-module-output-as-a-registered-variable-for-looping/15569/2 "2014-06-28T01:07:42Z")

</div>

There's a nested dictionary inside the item that you're missing. I just  
tried your playbook, but made this change

when: item.value.state is defined and item.value.state == 'running'

It worked for me then.

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [June 28, 2014, 1:12am UTC](https://forum.ansible.com/t/a-problem-with-using-the-virt-module-output-as-a-registered-variable-for-looping/15569/3 "2014-06-28T01:12:13Z")

</div>

HI Dustin,

You are 100% right. Why I missed the obvious? ☹ Time for more coffee 🙂

Thanks!

– Zack
