diff --git a/playbooks/tasks/web/nagios-ansible.cfg.j2 b/playbooks/tasks/web/nagios-ansible.cfg.j2 index d4f0ee9..7c5e9aa 100644 --- a/playbooks/tasks/web/nagios-ansible.cfg.j2 +++ b/playbooks/tasks/web/nagios-ansible.cfg.j2 @@ -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 diff --git a/playbooks/tasks/web/nagios.yml b/playbooks/tasks/web/nagios.yml index 96426aa..3a9925a 100644 --- a/playbooks/tasks/web/nagios.yml +++ b/playbooks/tasks/web/nagios.yml @@ -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