2021-01-03 15:10:04 +00:00
|
|
|
# {{ 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 %}
|
|
|
|
|
2022-01-20 08:54:06 +00:00
|
|
|
{% 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 %}
|
2021-01-03 15:10:04 +00:00
|
|
|
|
2022-01-20 08:54:06 +00:00
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% elif value is iterable and not value is string %}
|
2024-02-20 08:48:57 +00:00
|
|
|
vars.{{ var }} = [ "{{ value|join('", "') }}" ]
|
2022-01-20 08:54:06 +00:00
|
|
|
{% 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 %}
|
2021-01-03 15:10:04 +00:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
{% endfor %}
|