I have a jinja template file that's iterating through the play hosts and
checking which site each hosts belongs to that should output like this:
192.168.1.1, 192.168.1.2, 192.168.1.3,
{%- for host in play_hosts %}{% if hostvars[host]['site'] == site %}{{ host
}}{% if not loop.last %}, {% endif %}{% endif %}{% endfor -%}
However, I'm getting this jinja output instead. It's not suppressing the
separator on the last loop item iteration...
192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4,
If I remove the if check for the site variable it correctly removes the
seperator from the last loop iterate. However, now I have both sites in my
output which I don't want.
{%- for host in play_hosts %}{% if hostvars[host]['site'] == site %}{{ host
}}{% endif %}{% endfor -%}
192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4, 192.168.2.1,
192.168.2.2, 192.168.2.3, 192.168.2.4
Any Idea's on how to fix this?
--
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/b803a4b7-37df-4a67-b72d-ad7f622f362f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.