12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #
- # {{ node_id }}
- #
- {%- set roles = node_config.get ('roles', []) %}
- {%- set sites = node_config.get ('sites', []) %}
- {%- if node_config.get ('primary_ips', False) %}
- {%- set address = node_config['primary_ips'].get ('v4', '') %}
- {%- set address6 = node_config['primary_ips'].get ('v6', '') %}
- {%- else %}
- {%- set address = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v4') %}
- {%- set address6 = salt['ffho_net.get_loopback_ip'] (node_config, node_id, 'v6') %}
- {%- endif %}
- {%- set monitoring_config = node_config.get ('monitoring', {}) %}
- {%- set status = node_config.get ('status', 'active') %}
- {%- if 'icinga2server' not in roles %}
- object Endpoint "{{ node_id }}" {
- host = "{{ node_id }}"
- }
- object Zone "{{ node_id }}" {
- endpoints = [ "{{ node_id }}" ]
- parent = "master"
- }
- {%- endif %}
- object Host "{{ node_id }}" {
- import "generic-host"
- display_name = "{{ node_id }}"
- address = "{{ address }}"
- address6 = "{{ address6 }}"
- {%- if status != 'active' %}
- # This node has status {{ status }}, don't whine about anything here
- enable_notifications = false
- {%- endif %}
- vars.os = "Linux"
- vars.roles = [
- {%- for role in roles|sort %}
- "{{ role }}",
- {%- endfor %}
- ]
- vars.sites = [
- {%- for site in sites|sort %}
- "{{ site }}",
- {%- endfor %}
- ]
- {%- if 'host_vars' in monitoring_config %}
- # Host vars for node
- {%- for key, value in monitoring_config.get ('host_vars').items ()|sort %}
- vars.{{ key }} = "{{ value }}"
- {%- endfor %}
- {%- endif %}
- {%- if 'service_param' in monitoring_config %}
- # Service params
- vars.service_param = {
- {%- for service, params in monitoring_config.get ('service_param').items ()|sort %}
- "{{ service }}" = {
- {%- for entry, value in params.items ()|sort %}
- "{{ entry }}" = "{{ value }}",
- {%- endfor %}
- },
- {%- endfor %}
- }
- {%- endif %}
- }
|