diff --git a/playbooks/tasks/web/nagios-ansible.cfg.j2 b/playbooks/tasks/web/nagios-ansible.cfg.j2 index 1b76062..8e76064 100644 --- a/playbooks/tasks/web/nagios-ansible.cfg.j2 +++ b/playbooks/tasks/web/nagios-ansible.cfg.j2 @@ -1,5 +1,9 @@ -# This file is managed via Ansible -# Any changes made WILL be overwritten +# +# STOP +# +# This file is managed via Ansible; any changes made WILL be overwritten +# If you need to add site-specific configuration, do it in another file! +# # Templates define host { @@ -37,18 +41,27 @@ define contact { email rehashedsalt@cock.li } -# Default hostgroup and its checks +# Default hostgroup define hostgroup { hostgroup_name ansible alias Ansible-managed Hosts } # Commands +# Everything here is defined in nagios_commands +{% if nagios_commands is defined %} +{% for command in nagios_commands %} define command { - # This command is included in the container image - command_name check_nrpe - command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ + command_name {{ command.name }} + command_line {{ command.line }} + {% if command.extra is defined %} + {% for kvp in command.extra %} + {{ kvp.key }} {{ kvp.value }} + {% endfor %} + {% endif %} } +{% endfor %} +{% endif %} # Services # Everything here is defined in nagios_services diff --git a/playbooks/tasks/web/nagios.yml b/playbooks/tasks/web/nagios.yml index 31d6f15..c7d0493 100644 --- a/playbooks/tasks/web/nagios.yml +++ b/playbooks/tasks/web/nagios.yml @@ -5,6 +5,10 @@ - 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_commands: + # This command is included in the container image + - name: check_nrpe + command: "$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$" nagios_services: # Agentless checks - name: HTTP