try some logic in nagios jinja template to allow for hosts not to be defined

This commit is contained in:
Stephen Smoogen 2017-12-01 01:44:30 +00:00
parent d4042134d4
commit 36cfe3a769
16 changed files with 21 additions and 15 deletions

View file

@ -26,3 +26,9 @@ nrpe_procs_crit: 1400
collectd_graphite: True
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q root@bastion13.fedoraproject.org"'
nagios_Check_Services:
nrpe: false
sshd: false
swap: false
ping: false

View file

@ -18,7 +18,7 @@ define hostgroup{
define hostgroup{
hostgroup_name mincheckgrp
alias mincheckgrp
members {% for host in groups['all'] %}{% if hostvars[host].nagios_Check_Services['nrpe'] != true %}{{host}}, {% endif %}{% endfor %}
members {% for host in groups['all'] %}{% if hostvars[host].nagios_Check_Services['nrpe'] != true and hostvars[host].nagios_Check_Services['ping'] == true %}{{host}}, {% endif %}{% endfor %}
}

View file

@ -1,6 +1,6 @@
define hostgroup {
hostgroup_name CheckSwap
alias Swap-Is-Low
members {% for host in groups['all'] %}{% if hostvars[host].nagios_Check_Services['swap'] == true %}{{host}}{% if not loop.last %},{% endif %} {% endif %} {% endfor %}
members {% for host in groups['all'] %}{% if hostvars[host].nagios_Check_Services['swap'] == true and hostvars[host].nagios_Check_Services['ping'] == true %}{{host}}{% if not loop.last %},{% endif %} {% endif %} {% endfor %}
}

View file

@ -3,6 +3,6 @@
define hostgroup {
hostgroup_name vpnclients
alias vpnclients
members !download-rdu01.fedoraproject.org, !virthost-rdu01.fedoraproject.org, !bastion02.phx2.fedoraproject.org, {% for host in groups['all'] %}{% if ( hostvars[host].vpn == true ) %}{{host}},{% endif %} {% endfor %}
members {% for host in groups['all'] %}{% if ( hostvars[host].vpn == true ) and ( hostvars[host].nagios_Check_Services['ping'] == true ) %}{{host}},{% endif %} {% endfor %}
}

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'bodhost' %}
{% if hostvars[host].datacenter == 'bodhost' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'coloamer' %}
{% if hostvars[host].datacenter == 'coloamer' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'dedicatedsolutions' %}
{% if hostvars[host].datacenter == 'dedicatedsolutions' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'host1plus' %}
{% if hostvars[host].datacenter == 'host1plus' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'ibiblio' %}
{% if hostvars[host].datacenter == 'ibiblio' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'internetx' %}
{% if hostvars[host].datacenter == 'internetx' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'osuosl' %}
{% if hostvars[host].datacenter == 'osuosl' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,4 +1,4 @@
{% for host in vars["phx2_external"] %}
{% for host in vars["phx2_external"] and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
host_name {{ host }}
alias {{ host }}

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'phx2' %}
{% if hostvars[host].datacenter == 'phx2' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if hostvars[host].nagios_Check_Services['nrpe'] == true %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'rdu-cc' %}
{% if hostvars[host].datacenter == 'rdu-cc' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'staging' %}
{% if hostvars[host].datacenter == 'staging' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if hostvars[host].nagios_Check_Services['nrpe'] == true %}
use defaulttemplate

View file

@ -1,5 +1,5 @@
{% for host in groups['all'] %}
{% if hostvars[host].datacenter == 'tummy' %}
{% if hostvars[host].datacenter == 'tummy' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if vars['nagios_location'] == 'internal' %}
use defaulttemplate