play_hosts
is a list of all machines for a play. I want to take these and use something like format()
to rewrite them like rabbitmq@%s
and
I believe another way would be using the joiner
global function, as you can read in http://jinja.pocoo.org/docs/2.9/templates/#list-of-global-functions:
A joiner is passed a string and will return that string every time it’s called, except the first time (in which case it returns an empty string). You can use this to join things
So your code would be something like:
[
{% set comma = joiner(",") %}
{% for host in play_hosts %}
{{ comma() }}
{{ "rabbitmq@%s"|format(host) }}
{% endfor %}
]