Last active
July 10, 2017 17:08
-
-
Save gkspranger/bcdbc7fb5813d4ddcb892a92348a62cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# loop thru all relevant nodes #} | |
{% for i in ansible_play_batch | sort %} | |
{# set the node name AND node vars #} | |
{% set node_name=i %} | |
{% set node_vars=hostvars[ i ] %} | |
{# define the nagios hostgroup vars associated with this node .. default to linux #} | |
{% if node_vars.nagios_hostgroups is defined %} | |
{% set node_hostgroups="linux," ~ node_vars.nagios_hostgroups %} | |
{% else %} | |
{% set node_hostgroups="linux" %} | |
{% endif %} | |
{# define the nagios hostgroup arr so we can do some easy checking #} | |
{% set node_hostgroups_arr=node_hostgroups.split(",") %} | |
############################# | |
## START {{ node_name }} | |
############################# | |
define host { | |
use linux-server | |
host_name {{ node_name }} | |
address {{ node_vars.ansible_ec2_local_ipv4 | default('127.0.0.1') }} | |
hostgroups {{ node_hostgroups }} | |
# it's nice to have some ec2 data as nagios host vars | |
_ec2_instance_id {{ node_vars.ansible_ec2_instance_id }} | |
_ec2_instance_type {{ node_vars.ansible_ec2_instance_type }} | |
_ec2_placement_availability_zone {{ node_vars.ansible_ec2_placement_availability_zone }} | |
_ec2_placement_region {{ node_vars.ansible_ec2_placement_region }} | |
_ec2_security_groups {{ node_vars.ansible_ec2_security_groups }} | |
} | |
############################# | |
## NRPE dependencies | |
## if NRPE aint available, these will fail | |
############################# | |
# SWAP | |
define servicedependency { | |
host_name {{ node_name }} | |
service_description NRPE Port | |
dependent_host_name {{ node_name }} | |
dependent_service_description Swap | |
execution_failure_criteria n | |
notification_failure_criteria w,u,c | |
} | |
# CPU | |
define servicedependency { | |
host_name {{ node_name }} | |
service_description NRPE Port | |
dependent_host_name {{ node_name }} | |
dependent_service_description CPU | |
execution_failure_criteria n | |
notification_failure_criteria w,u,c | |
} | |
# you can go on and on here .. | |
# for a very long time .. | |
############################# | |
## END {{ node_name }} | |
############################# | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment