I'm trying to figure out how to pass statement that will match multiple
hostnames instead of just one. I know how to do it with a group in the
hosts file, but I need it to be something I set in the defaults part of the
role. I'm sure sure the answer is really easy but I'm just getting used to
Jinja. Here's my example...
*hosts file:*
[group1]
system1
system2
system3
roles/fubar/templates/mytest.j2
{% if inventory_hostname == "server1" %}
This is a test
{% endif %}
This works... but what if I want this line on server1 and server3?
Preferably something a role assigned in defaults/main.yml file like:
ImportantServers: [ 'server1' , 'server3' ]
{% if inventory_hostname in groups[ 'ImportantServers'] %}
This is a test
{% endif %}
That doesn't work however. I think it's because the groups is referring to
the hosts file and not looking at the defaults. If someone could tell me
what I'm doing wrong and not shame me too badly that would be great.
--
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/9ff24759-4e98-49db-b66a-5234b5450dfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.