How to flatten host vars into a string.

Hello,

I’m trying to build a String based on host vars from a group.

I see how to loop thru host in a group

{% for host in groups['app_servers'] %}
   {{ hostvars[host]['my_cool_var'] }}
{% endfor %}
But not how to flatten this into a string to get :
my_cool_val1, my_cool_val2,...,my_cool_vallast
Thanks for you help

Alain

something like

{% for cmd in tester_commands_root_extra %}{{ cmd }}{% if not loop.last %}, {% endif %}{% endfor %}

Super. Thanks for your quick reply. Exactly what I needed

Alain

several ways, with a for loop:

{% for host in groups['app_servers'] %}{{
hostvars[host]['my_cool_var'] }}{% if not loop.last %},{% endi f%}{%
endfor %}