Mike,

This may give you some insight:

https://github.com/basho-labs/ansible-riak/blob/develop/examples/form_cluster.yml

Particularly:   

primary_node: "{{ 
hostvars[groups['riak_cluster'][0]]['riak_outputs']['node_name'] }}"

- James



On Wednesday, April 1, 2015 at 5:16:12 PM UTC-4, MikeA wrote:
>
> I'm launching a cluster of ec2 instances and would like one (don't care 
> which one) of them to become a head node and pass it's IP to the other 
> cluster members. I've been looking for an easy way to do this but could not 
> fine one so would appreciate any assistance.
>
> Here is what I've got.
> from my main playbook I'm calling a sub playbook that launches the ec2 
> instances. there i add the instances to the {{ group_name }} group. where 
> group_name is a variable defined in a var file.
>
> later on the main playbook I'd like to pull one of the IP's and feed it 
> into a startup script to be called on all the hosts.
>
> I could not find a way to extract element 0 from the group_name var 
> array.I tried this: set_fact: headnode={{ groups[[{{ group_name }}][0]] }} 
> but it did not work. I had to use the actual group_var value and then I got 
> the IP but it was not a clean string rather it looked like this: 
> [u'10.77.0.211', 
>
> Any idea how to get a clean IP from the group_name set? BDW in the sub 
> playbook where I launch the instances I register the private ip's from the 
> instances: set_fact: private_ips: "{{ ec2.tagged_instances|join(', ', 
> attribute='private_ip') }}" but I cannot refer to this variable back in the 
> main playbook.
>
> thanks in advance.
>

-- 
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/9ed4e33f-6a1d-4657-88e7-b86594be83c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to