45 lines
1.3 KiB
Text
45 lines
1.3 KiB
Text
|
# {{ ansible_managed }}
|
||
|
{% for name, template in icinga2_templates.items() %}
|
||
|
|
||
|
template {{ template.type|title }} "{{ name }}" {
|
||
|
{% if template.import is defined %}
|
||
|
import "{{ template.import }}"
|
||
|
{% endif %}
|
||
|
{% if template.options is defined %}
|
||
|
{% for option, value in template.options.items() %}
|
||
|
{% if value is iterable and not value is string %}
|
||
|
{% if option in ['states', 'types'] %}
|
||
|
{{ option }} = [ {{ value|join(', ') }} ]
|
||
|
{% else %}
|
||
|
{{ option }} = [ "{{ value|join(', "') }}" ]
|
||
|
{% endif %}
|
||
|
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
||
|
{{ option }} = {{ value }}
|
||
|
{% else %}
|
||
|
{{ option }} = "{{ value }}"
|
||
|
{% endif %}
|
||
|
{% endfor %}
|
||
|
{% endif %}
|
||
|
{% if template.vars is defined %}
|
||
|
|
||
|
{% for var, value in template.vars.items() %}
|
||
|
{% if value is sameas True %}
|
||
|
vars.{{ var }} = true
|
||
|
{% elif value is sameas False %}
|
||
|
vars.{{ var }} = false
|
||
|
{% elif value is iterable and not value is string %}
|
||
|
{% if var in ['states', 'types'] %}
|
||
|
vars.{{ var }} = [ {{ value|join(', ') }} ]
|
||
|
{% else %}
|
||
|
vars.{{ var }} = [ "{{ value|join(', "') }}" ]
|
||
|
{% endif %}
|
||
|
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
||
|
vars.{{ var }} = {{ value }}
|
||
|
{% else %}
|
||
|
vars.{{ var }} = "{{ value }}"
|
||
|
{% endif %}
|
||
|
{% endfor %}
|
||
|
{% endif %}
|
||
|
}
|
||
|
{% endfor %}
|