From 0bfcd5ea2b38fa4183b7ef1742c916162792a0fe Mon Sep 17 00:00:00 2001 From: Salt Date: Wed, 23 Feb 2022 16:44:42 -0600 Subject: [PATCH] Have Nagios ignore decom hosts For HOSTS, mind. Services are still gonna need some love Might honestly just have this operate off of host vars instead, lower the number of lookups, yaknow? --- roles/nagios/templates/nagios-ansible.cfg.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/nagios/templates/nagios-ansible.cfg.j2 b/roles/nagios/templates/nagios-ansible.cfg.j2 index 8c8690d..39275ee 100644 --- a/roles/nagios/templates/nagios-ansible.cfg.j2 +++ b/roles/nagios/templates/nagios-ansible.cfg.j2 @@ -137,7 +137,7 @@ define hostgroup { {% endfor %} # Hosts -{% for host in query('netbox.netbox.nb_lookup', 'devices', api_endpoint='https://netbox.desu.ltd', token=netbox_token) + query('netbox.netbox.nb_lookup', 'virtual-machines', api_endpoint='https://netbox.desu.ltd', token=netbox_token)%} +{% for host in query('netbox.netbox.nb_lookup', 'devices', api_filter='status=active', api_endpoint='https://netbox.desu.ltd', token=netbox_token) + query('netbox.netbox.nb_lookup', 'virtual-machines', api_filter='status=active', api_endpoint='https://netbox.desu.ltd', token=netbox_token)%} {% if host.value.primary_ip %} {% for tag in host.value.tags %} {% if tag.slug == "nagios" %} @@ -176,6 +176,7 @@ define host { {% elif service.value.virtual_machine %} {% set host_name = service.value.virtual_machine.name %} {% endif %} +{% if host_name is defined %} # {{ host_name }} - {{ service.value.display }} # Description: {{ service.value.description }} # Created: {{ service.value.created }} @@ -231,4 +232,5 @@ define service { {% endif %} {# #} {% endfor %} +{% endif %} {% endfor %}