Flatten a dict-list in a template

So I’m trying to setup a shinken-enviroment and it has a similar syntax to Nagios.
In the contactgroups.cfg I need to put all my admins on one line.
Is there anyway to take entries from a list of dicts and flatten them to one line?
Below is my test-example

`

So I'm trying to setup a shinken-enviroment and it has a similar
syntax to Nagios.
In the contactgroups.cfg I need to put all my admins on one line.
Is there anyway to take entries from a list of dicts and flatten them
to one line?
Below is my test-example
>
---
  - hosts: localhost
    remote_user: root
    vars:
      users:
       - name: Andrew
       - name: Doug
       - name: Paul
       - name: ipphone
    tasks:
     - debug: var=users
     - name: test
       template: src=../templates/test.j2
                 dest=/home/root/test.cfg

>
The template:
>
define contactgroup{
    contactgroup_name Admins
    alias Seamless_internal_admins
    members {{ users.name }}
}
>

result:
>
define contactgroup{
    contactgroup_name JAPS
    alias Seamless_internal_admins
    members Doug
}
>

Desired result:
>
define contactgroup{
    contactgroup_name JAPS
    alias Seamless_internal_admins
    members Andrew,Doug,Paul,ipphone
}
>

--
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 ansible-project+unsubscribe@googlegroups.com
<mailto:ansible-project+unsubscribe@googlegroups.com>.
To post to this group, send email to ansible-project@googlegroups.com
<mailto:ansible-project@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2ce4fa5b-80e9-4e33-915b-7f1361027eb2%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/2ce4fa5b-80e9-4e33-915b-7f1361027eb2%40googlegroups.com?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/d/optout.

Modify your template like this:

define contactgroup{
    contactgroup_name Admins
    alias Seamless_internal_admins
    members {{ users[0].name }}{% for user in users[1:] %},{{ user.name
}}{% endfor %}
}

How do you know all of this! You are amazing! :slight_smile:

It worked