47 lines
1.4 KiB
Django/Jinja
47 lines
1.4 KiB
Django/Jinja
# {{ ansible_managed }}
|
|
{% for name, service in icinga2_services.items() %}
|
|
|
|
apply Service "{{ name }}" {
|
|
import "{{ service.import|default('generic-service') }}"
|
|
check_command = "{{ service.check_command }}"
|
|
assign where {{ service.assign }}
|
|
{% if service.options is defined %}
|
|
{% for option, value in service.options.items() %}
|
|
{% if value is sameas True %}
|
|
{{ option }} = true
|
|
{% elif value is sameas False %}
|
|
{{ option }} = false
|
|
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
|
{{ option }} = {{ value }}
|
|
{% else %}
|
|
{{ option }} = "{{ value }}"
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if service.vars is defined %}
|
|
|
|
{% for var, value in service.vars.items() %}
|
|
{% if value is sameas True %}
|
|
vars.{{ var }} = true
|
|
{% elif value is sameas False %}
|
|
vars.{{ var }} = false
|
|
{% elif value is mapping %}
|
|
{% for name, config in value.items() %}
|
|
vars.{{ var }}["{{ name }}"] = {
|
|
{% for option, v in config.items() %}
|
|
{{ option }} = {% if v is number %}{{ v }}{% else %}"{{ v|replace('\n', ' ')|trim }}"{% endif %}
|
|
|
|
{% endfor %}
|
|
}
|
|
{% endfor %}
|
|
{% elif value is iterable and not value is string %}
|
|
vars.{{ var }} = [ "{{ value|join('", "') }}" ]
|
|
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
|
vars.{{ var }} = {{ value }}
|
|
{% else %}
|
|
vars.{{ var }} = "{{ value|replace('\n', ' ')|trim }}"
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
}
|
|
{% endfor %}
|