Hi Michael,

I tried using the {{ hostvars[inventory_hostname] trick but that variable
space does not include variables defined in a role such as 
"myrole/vars/main.yaml."
How can I programmatically reference variables defined within a role?

Thank you,
--Ed

On Wednesday, November 27, 2013 4:52:03 PM UTC-8, Michael DeHaan wrote:
>
> You can build variables dynamically through hostvars, which is a hash of 
> all variables, host by host:
>
> {{ hostvars[inventory_hostname]["ansible_" + main_nic].ipv4.address }}
>
> inventory_hostname is the name of the current host in the host loop.
>
> (Nesting templates in templates definitely will not work)
>
>
>
> On Wed, Nov 27, 2013 at 7:48 PM, Gonzalo Servat <[email protected]<javascript:>
> > wrote:
>
>> Hi All,
>>
>> This might be more of a Jinja question, but I couldn't find an answer to 
>> this.
>>
>> Say I have an inventory value that stores the main NIC name and I want to 
>> lookup the IP address for it from a fact. How can this be done in the one 
>> line? Non working example:
>>
>> debug: msg="ip address is {{ ansible_{{ main_nic }}.ipv4.address }}"
>>
>> GS
>>  
>> -- 
>> 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:>.
>> 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d344a5c3-a7aa-4816-8200-0eb52285b2bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to