I believe there was a ticket about hostvars not including *all* of the variables, which it should, that should now be resolved.
If you still see this in 1.6 let me know. On Thu, May 1, 2014 at 1:25 PM, <[email protected]> wrote: > 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]> 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]. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Michael DeHaan <[email protected]> >> >> 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<https://groups.google.com/d/msgid/ansible-project/d344a5c3-a7aa-4816-8200-0eb52285b2bf%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%2BnsWgxBsENArnoBC3i-26zxROhFMuxLnVJKMzMOjeN%2BTHskhw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
