jepper
(jepper)
1
In a template, I loop over a group of fusemq hosts defined in my invetory file e.g.
fuseMQ_URL=failover:( {% for host in groups[‘fusemq’] %} tcp://{{ host }}, {% endfor %} )
The result is of course, a trailing comma - how can I avoid this?
fuseMQ_URL=failover:( tcp://fusemq01, tcp://fusemq02, )
Try the join filter in Jinja:
{{ groups[‘fusemq’]|join(’ ,') }}
jepper
(jepper)
3
Will that not generate a list as follows
fusemq01, fusemq02
it does not take into account “tcp://”
You may want something like this (untested):
{% for host in groups[‘fusemq’] %} tcp://{{ host }}{% if not loop.last %}, {% endif %}{% endfor %}
OK try this...
"tcp://{{ groups['fusemq']|join(',tcp://') }}"
Not exactly pretty but better than a for loop with conditionals.
<tim/>