Allow the addition of custom checks based on config_context, add roles to hostgroups
This commit is contained in:
parent
18655b7d62
commit
7669234df9
@ -77,15 +77,26 @@ define service {
|
||||
{% endif %}
|
||||
|
||||
# Hostgroups
|
||||
# Everything here is dynamically-generated based on tags from Netbox
|
||||
{% for role in query('netbox.netbox.nb_lookup', 'device-roles', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %}
|
||||
# Device Role: {{ role.value.name }}
|
||||
# Description: {{ role.value.description }}
|
||||
# Created: {{ role.value.created }}
|
||||
# Updated: {{ role.value.last_updated }}
|
||||
define hostgroup {
|
||||
hostgroup_name role-{{ role.value.slug }}
|
||||
alias {{ role.value.display }}
|
||||
}
|
||||
{% endfor %}
|
||||
{% for tag in query('netbox.netbox.nb_lookup', 'tags', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %}
|
||||
# Tag: {{ tag.value.name }}
|
||||
# Description: {{ tag.value.description }}
|
||||
define hostgroup {
|
||||
hostgroup_name tag-{{ tag.value.slug }}
|
||||
alias {{ tag.value.display }}
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
# This list of hosts is dynamically generated based on devices and VMs tagged with "nagios" in Netbox
|
||||
# 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)%}
|
||||
{% if host.value.primary_ip %}
|
||||
{% for tag in host.value.tags %}
|
||||
@ -98,12 +109,24 @@ define host {
|
||||
hostgroups ansible{% for tag in host.value.tags %},tag-{{ tag.slug }}{% endfor %}
|
||||
|
||||
}
|
||||
{% if host.value.config_context.extra_checks is defined %}
|
||||
{% for check in host.value.config_context.extra_checks %}
|
||||
define service {
|
||||
# Config Context check
|
||||
use ansible-generic-service
|
||||
service_description {{ check.description }}
|
||||
check_command {{ check.command }}
|
||||
host_name {{ host.value.name }}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# #}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
# This list of services is dynamically generated based on services in Netbox and how they're tagged
|
||||
# Services unique to hosts
|
||||
{% for service in query('netbox.netbox.nb_lookup', 'services', api_endpoint='https://netbox.desu.ltd', token=netbox_token) %}
|
||||
{% if service.value.device %}
|
||||
{% set host_name = service.value.device.name %}
|
||||
|
Loading…
Reference in New Issue
Block a user