add_host access host variables from in-memory group

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

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