# Issue with registered variables

**URL:** <https://forum.ansible.com/t/issue-with-registered-variables/23207>\
**Category:** Ansible Project\
**Created:** [December 9, 2016, 1:08am UTC](https://forum.ansible.com/t/issue-with-registered-variables/23207 "2016-12-09T01:08:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cann](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@Cann](https://forum.ansible.com/u/Cann)\
**Post date:** [December 9, 2016, 1:08am UTC](https://forum.ansible.com/t/issue-with-registered-variables/23207/1 "2016-12-09T01:08:25Z")

</div>

Hi guys , I am having a really hard time with **registered variables**. I banged my head around all day… but could not figure this out. ☹

I simply want to register my task result as a variable and access it later on.

This is my **debug: var=** result: [https://pastebin.mozilla.org/8950629](https://pastebin.mozilla.org/8950629)  
and I simply want to get **dns\_name**

I call it like this:

> - name: Wait for servers to boot up  
> wait\_for:  
> host: “{{ item.dns\_name }}”  
> port: 22  
> delay: 30  
> timeout: 300  
> state: started  
> with\_items: ec2\_result.instances

But I am getting error saying that

fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: "the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘unicode object’ has no attribute ‘dns\_name’\n\n

Can you guys please point me to right direction?  
Thank you.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [December 9, 2016, 2:08am UTC](https://forum.ansible.com/t/issue-with-registered-variables/23207/2 "2016-12-09T02:08:33Z")

</div>

As of Ansible 2.2 with\_items does not support bare variables.

As such you need to use:

with\_items: “{{ ec2\_result.instances }}”

Otherwise it will treat ec2\_result.instances as a string.

---

<div class="post-metadata">

**Author:** ![Cann](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@Cann](https://forum.ansible.com/u/Cann)\
**Post date:** [December 9, 2016, 4:08am UTC](https://forum.ansible.com/t/issue-with-registered-variables/23207/3 "2016-12-09T04:08:45Z")

</div>

Thank you so much Matt Martz! You’re awesome!
