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 %}