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