42 lines
1.1 KiB
Text
42 lines
1.1 KiB
Text
|
# {{ ansible_managed }}
|
||
|
{% for name, host in icinga2_hosts.items() %}
|
||
|
|
||
|
object Host "{{ name }}" {
|
||
|
import "{{ host.template }}"
|
||
|
{% if host.address is defined %}
|
||
|
address = "{{ host.address }}"
|
||
|
{% endif %}
|
||
|
{% if host.address6 is defined %}
|
||
|
address6 = "{{ host.address6 }}"
|
||
|
{% endif %}
|
||
|
{% if host.zone is defined %}
|
||
|
zone = "{{ host.zone }}"
|
||
|
{% endif %}
|
||
|
{% if host.vars is defined %}
|
||
|
|
||
|
{% for var, value in host.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 }}"{% 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 }}"
|
||
|
{% endif %}
|
||
|
{% endfor %}
|
||
|
{% endif %}
|
||
|
}
|
||
|
{% endfor %}
|