Browse Source

icinga2: generate location info to icinga hosts

Dominique Flemming-Schmidt 3 years ago
parent
commit
48c3a70d88
1 changed files with 21 additions and 0 deletions
  1. 21 0
      icinga2/host.conf.tmpl

+ 21 - 0
icinga2/host.conf.tmpl

@@ -6,6 +6,7 @@
 {%- 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 %}
@@ -68,6 +69,26 @@ object Host "{{ node_id }}" {
 	}
 {%- 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 %}