# add\_host access host variables from in-memory group

**URL:** <https://forum.ansible.com/t/add-host-access-host-variables-from-in-memory-group/19645>\
**Category:** Ansible Project\
**Created:** [October 29, 2015, 1:37am UTC](https://forum.ansible.com/t/add-host-access-host-variables-from-in-memory-group/19645 "2015-10-29T01:37:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@K\_Cheng](https://forum.ansible.com/u/K_Cheng)\
**Post date:** [October 29, 2015, 1:37am UTC](https://forum.ansible.com/t/add-host-access-host-variables-from-in-memory-group/19645/1 "2015-10-29T01:37:47Z")

</div>

Hey guys,

Just wondering whether there is a way to access the contents of a add\_host group?

EG:

> - name: Add newly created instance to host group created\_instances
> 
> add\_host:
> 
> hostname: “{{ item.private\_ip }}”
> 
> testvar: test\_variable

> public\_one: “{{ item.public\_ip }}”

> groups: created\_instances
> 
> with\_items: “{{ ec2.instances | default({}) }}”

- name: Get specific data from newly created instances

> debug: var="{{ item.testvar }}

> with\_items: created\_instances

At the moment, when I do the above, item is only the IP address (private ip address) and I can’t seem to get at anything specific. I’m using dynamic inventory and I was hoping not to have to rerun the dynamic inventory again seeing as I thought add\_host was supposed to add details to in-memory groups.

Regards

Karen

---

<div class="post-metadata">

**Author:** ![K\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@K\_Cheng](https://forum.ansible.com/u/K_Cheng)\
**Post date:** [October 31, 2015, 4:19am UTC](https://forum.ansible.com/t/add-host-access-host-variables-from-in-memory-group/19645/2 "2015-10-31T04:19:26Z")

</div>

Doesn’t matter, I’ve used add\_host and then called the group using hosts instead and I’ll just delegate back down to the localhost to perform the actions I need it to instead.

Karen
