On Saturday, September 13, 2014 1:20:44 AM UTC+7, Josh Smift wrote:

> This seems like the thing that someone else helped me figure out how to 
> do, e.g. I now have as part of my aws-launch.yml playbook: 
>
>   - name: Add new instance to a temporary group 
>     local_action: 
>       module: add_host 
>       name: "{{ item.public_ip }}" 
>       groups: newly_launched 
>       ec2_tag_Name: "{{ instance_hostname }}" 
>     with_items: ec2.instances 
>
> Does that help?
>

Thanks for the suggestion Josh, that seems like a promising lead, I didn't 
realize until now that add_host can *add host variables*, not just add 
hosts to groups. Except that, so far, I'm not sure that it works to set 
*new* host variables if the referenced host already existed in inventory. 
I've tried this:

- name: Set hostvar aliases
  add_host: >
    name='{{ item }}'
    zookeeper_myid='{{ hostvars[item].ec2_tag_ZooKeeperID }}'
    zookeeper_bind_address='{{ hostvars[item].ec2_private_ip_address }}'
  with_items: groups[zookeeper_ensemble_group]

which would get me what I'm wanting pretty readably, but it doesn't seem to 
work.

I tried changing hash_behaviour to "merge" just to see if that could allow 
this work, no dice. I'll have to dig further in implementation to 
understand, and this issue might be relevant since the above is a local 
action:

https://github.com/ansible/ansible/issues/5791

-Ches

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/77e590f7-894e-4aac-a378-c79706383cea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to