123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #
- # {{ node_id }}
- #
- {%- set roles = node_config.get ('roles', []) %}
- {%- set sites = node_config.get ('sites', []) %}
- {%- set address = salt['ffho_net.get_primary_ip'] (node_config, 'v4').ip %}
- {%- set address6 = salt['ffho_net.get_primary_ip'] (node_config, 'v6').ip %}
- {%- 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 %}
- ]
- {#- Bare-metal host #}
- {%- if node_config.get ('hardware', False) %}
- # Bare metal host
- vars.hardware = true
- vars.manufacturer = "{{ node_config['manufacturer']|replace ('"', '\"') }}"
- vars.model = "{{ node_config['model']|replace ('"', '\\"') }}"
- {%- endif %}
- {#- VM #}
- {%- if node_config.get ('virtual', False) %}
- # VM
- vars.virtual = true
- vars.vm = {
- "vcpus" = {{ node_config['vm_config']['vcpus'] }},
- "memory" = {{ node_config['vm_config']['memory'] }},
- "disk" = {{ node_config['vm_config']['disk'] }},
- }
- {%- endif %}
- {#- Special monitoring related config for this host? #}
- {%- 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 %}
- }
|