How do you know all of this! You are amazing! :)
It worked
Den onsdagen den 21:e maj 2014 kl. 13:30:18 UTC+2 skrev Ernest0x:
>
> On 05/21/14 12:59, Joachim Friberg wrote:
>
> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> 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>
> .
> 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 %}
> }
>
>
--
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/442152a4-47ae-4003-82e0-bed5122e71a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.