add_host access host variables from in-memory group

68 views
Skip to first unread message

K Cheng

unread,
Oct 28, 2015, 9:37:47 PM10/28/15
to Ansible Project
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 

K Cheng

unread,
Oct 31, 2015, 12:19:27 AM10/31/15
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages