The above imaginary syntax will not work, but this will :)  The groups
array contains the names of each host in each group, and this picks out the
first one in inventory order.

{{ hostvars[groups['databaseserver'][0]].ansible_eth0.ipv4.address }}

If using a template file versus inline in the playbook, I'd do this:

{# set db_head_node = groups['databaseserver'][0] #}
{{ hostvars[db_head_node].blarg }}

for readability purposes




On Tue, Jul 29, 2014 at 11:02 AM, Piet83 <[email protected]> wrote:

> Ok but what if I don't know the server name but only that it is an
> database server in amsterdam?
>
> Something like this, but then with the right syntax?
>
> {{ groups["databaseserver"] | {{ hostvars["amsterdam"] }} | {{
> ansible_eth0.ipv4.address }} }}
>
> Op dinsdag 29 juli 2014 14:23:04 UTC+2 schreef Brian Coca:
>
>> just do  {{ city }}​, if it is the 'current host', to access vars of
>> other hosts {{ hostvars['server3'].city }}
>>
>  --
> 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/0ec5b636-9383-4a80-9c51-28831b33406a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0ec5b636-9383-4a80-9c51-28831b33406a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgww0i%2BsLqg6v1vs59QoWLRpLxkTT1YCGZAX7YzYMt57VA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to