Modularize declaration of Nagios commands

This commit is contained in:
Salt 2021-09-07 13:31:04 -05:00
parent 2a7d343ef1
commit 1ca062d6ea
2 changed files with 23 additions and 6 deletions

View File

@ -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

View File

@ -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