Hey Morgan,
Thanks so much for this... all very good ideas, I see how they may work
outside of the current way I was thinking about this problem... will
definitely try a few out and let the list know where I land :)

matt



On Tue, Mar 25, 2014 at 2:27 PM, C. Morgan Hamill <[email protected]>wrote:

> Excerpts from Matt Coddington's message of 2014-03-25 14:15:18 -0400:
> > > > {% 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 }}"
> > >     {{ hostvars[host].ansible_eth0.ipv4.address }}
> > That's what i was afraid of... you're correct that explicitly referencing
> > those does work, and I can do this in the template by having different
> > cases for the different sets of servers (e.g. "if prod, use
> > ansible_bond0.ipv4.address, if staging use ansible_eth0.ipv4.address,
> > etc").  I was just hoping there was a way to abstract that if/then logic
> > into a common variable outside the template.
>
> Idea, untested:
>
> In your template:
>
>     {% for host in groups['uat-webapp']|sort %}
>     BalancerMember ajp://{{
> hostvars[host][hostvars[host][webapp_iface]].ipv4.address }}
>     {% endfor %}
>
> In your group_vars file:
>
>     webapp_iface: "ansible_bond0"
>
> Or what have you.
>
> Or this might work:
>
> Leave your template as is, and try putting in your group_vars file:
>
>     webapp_ip: "{{ hostvars[inventory_hostname].ansible_eth0.ipv4.address
> }}"
>
> Also, you might want to look into setting your own facts, as those are
> per-host.
> --
> 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/CAMfrSccOdFYNG7Dpx6vN2sQv4pBBPwayWrXOhuuLM2pMGpM4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to