Modularize contact definitions

This commit is contained in:
Salt 2021-10-06 15:30:12 -05:00
parent 37c55b9cb2
commit 4f07856028
2 changed files with 31 additions and 12 deletions

View File

@ -24,24 +24,36 @@ define service {
register 0
}
# Contacts
define contact {
contact_name salt
host_notifications_enabled 1
host_notification_period 24x7
host_notification_commands notify-host-by-email
service_notifications_enabled 1
service_notification_period 24x7
service_notification_commands notify-service-by-email
email rehashedsalt@cock.li
}
# Default hostgroup
define hostgroup {
hostgroup_name ansible
alias Ansible-managed Hosts
}
{% if nagios_contacts is defined %}
# Contacts
# Everything here is defined in nagios_contacts
{% for contact in nagios_contacts %}
define contact {
contact_name {{ contact.name }}
alias {{ contact.alias | default(contact.name, true ) }}
host_notifications_enabled {{ contact.host_notifications_enabled | default('1', true) }}
host_notification_period {{ contact.host_notification_period | default('24x7', true) }}
host_notification_options {{ contact.host_notification_options | default('d,u,r,f', true ) }}
host_notification_commands {{ contact.host_notification_commands }}
service_notifications_enabled {{ contact.service_notifications_enabled | default('1', true) }}
service_notification_period {{ contact.service_notification_period | default('24x7', true) }}
service_notification_options {{ contact.service_notification_options | default('w,c,r,f', true ) }}
service_notification_commands {{ contact.service_notification_commands }}
{% if contact.extra is defined %}
{% for kvp in contact.extra %}
{{ kvp.key }} {{ kvp.value }}
{% endfor %}
{% endif %}
}
{% endfor %}
{% endif %}
{% if nagios_commands is defined %}
# Commands
# Everything here is defined in nagios_commands

View File

@ -5,6 +5,13 @@
- name: template out config for nagios
template: src=nagios-ansible.cfg.j2 dest=/data/nagios/etc/objects/ansible.cfg owner=root group=root mode=0644
vars:
nagios_contacts:
- name: salt
host_notification_commands: notify-host-by-email
service_notification_commands: notify-service-by-email
extra:
- key: email
value: rehashedsalt@cock.li
nagios_commands:
# This command is included in the container image
- name: check_nrpe