Excerpts from Matt Coddington's message of 2014-03-24 22:58:50 -0400:
> Using Ansible 1.5.3
>
> I'm having some trouble with a situation where I have a variable that I'd
> like to use in a template that uses "hostvars" but the variable in question
> is calculated from facts.
>
> I have a template that looks like this:
>
> {% for host in groups['uat4-webapp']|sort %}
> BalancerMember ajp://{{ hostvars[host].webapp_ip }}:8009 loadfactor=20
> {% endfor %}
>
> The "webapp_ip" variable is calculated like this in a group_vars file:
>
> webapp_ip: "{{ ansible_eth0.ipv4.address }}"
> Is this something that should work, or should I be looking to accomplish
> this a different way?
Ansible seems to evaluate somewhat lazily, so "{{ansible_eth0.ipv4.address}}"
get evaluated in the context of the current host.
You'll probably need to be explicit:
{{ hostvars[host].ansible_eth0.ipv4.address }}
--
Morgan Hamill
--
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/1395750965-sup-5766%40al.wesleyan.edu.
For more options, visit https://groups.google.com/d/optout.