123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #
- # {{ node_id }}
- #
- {%- set roles = node_config.get ('roles', [])|sort %}
- {%- set sites = node_config.get ('sites', [])|sort %}
- {%- set tags = node_config.get ('tags', [])|sort %}
- {%- 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 location = node_config.get ('location', {}) %}
- {%- set status = node_config.get ('status', 'active') %}
- {%- if 'icinga2server' not in roles and node_config.get('platform') == 'linux' %}
- 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 = "{{ node_config.get('platform') or "" }}"
- vars.role = "{{ node_config.get('role', '') }}"
- vars.roles = [
- {%- for role in roles %}
- "{{ role }}",
- {%- endfor %}
- ]
- vars.sites = [
- {%- for site in sites %}
- "{{ site }}",
- {%- endfor %}
- ]
- vars.tags = [
- {%- for tag in tags %}
- "{{ tag }}",
- {%- 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 %}
- {#- Location #}
- {%- if location %}
- # Location
- vars.location = {
- {%- if "region" in location %}
- "region" = {
- "code" = "{{ location['region'].get("code") }}",
- "name" = "{{ location['region'].get("name") }}",
- },
- {%- endif %}
- {%- if "site" in location %}
- "site" = {
- "code" = "{{ location['site'].get("code") }}",
- "desc" = "{{ location['site'].get("desc") }}",
- }
- {%- endif %}
- }
- {%- 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 %}
- {%- if value is boolean %}
- "{{ entry }}" = {{ value|lower }},
- {%- else %}
- "{{ entry }}" = "{{ value }}",
- {%- endif %}
- {%- endfor %}
- },
- {%- endfor %}
- }
- {%- endif %}
- }
|