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
}
>
define contactgroup{
contactgroup_name Admins
alias Seamless_internal_admins
members {{ users[0].name }}{% for user in users[1:] %},{{ user.name
}}{% endfor %}
}