Thanks Michael, 

Just out of curiosity, I can't seem to find this type of info in the 
documentation. Is it in there somewhere?

On Monday, December 23, 2013 5:59:52 PM UTC+1, Michael DeHaan wrote:
>
> This part:
>
> {{ hostvars[host][groups['tag_Group_MySQL'][0]] }}
>
> is incorrect.
>
> Try this:
>
> {{ hostvars[ groups['tag_Group_MySQL'][0] ][ variable_name ] }}
>
>
>
>
>
>
>
>
> On Sat, Dec 21, 2013 at 2:46 PM, Trond Hindenes 
> <[email protected]<javascript:>
> > wrote:
>
>> I'm trying to build a paybook which will provision 2 compute instances on 
>> amazon ec2, and then install mysql on one of them, and apache2/wordpress on 
>> the other. 
>>
>> I'm stuck with trying to configure the wordpress instance's wp-config 
>> file which needs to point to the mysql instance. I don't know the name/ip 
>> address of these nodes when the playbook starts, so I'm using the Ansible 
>> modules for provisioning them and adding them to their respective host 
>> groups after provisioning. I can save the output of the provisioning task 
>> as a variable, but this var is not accessible outside of the node which ran 
>> the provisioning job.
>>
>> From any node I can use the "groups['tag_Group_MySQL']", but this only 
>> lets me access the instance's public ip, not the other facts about it.
>>
>> So, I need to access hostvars of a host which needs to be dynamically 
>> assigned. I tried something like {{ 
>> hostvars[host][groups['tag_Group_MySQL'][0]]}} but that doesnt work. I 
>> don't even know if "nested vars" is supported.
>>
>> Any pointers on how to solve this issue will de deeply appreciated! The 
>> current playbook can be found at 
>> https://github.com/trondhindenes/AnsibleTest/tree/master/ec2-env
>>  
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Michael DeHaan <[email protected] <javascript:>>
> CTO, AnsibleWorks, Inc.
> http://www.ansibleworks.com/
>
>  

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to