diff options
author | Micah Anderson <micah@riseup.net> | 2013-02-19 15:18:30 -0500 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2013-02-19 15:18:30 -0500 |
commit | 4dcc5f884cd22d0673f6493799ace2f03a9e66fe (patch) | |
tree | 3f3f5c217c40f3037c1b2a9cd8da3fe91fdd8389 /puppet/modules/site_nagios/manifests | |
parent | 253b765620961bbc9d96e8f3653b0b9693d29811 (diff) | |
parent | 2e5eec3856b58aaff0a2049599a6455e6ff91122 (diff) |
Merge remote-tracking branch 'origin/release/v0.2.0'0.2.0
Diffstat (limited to 'puppet/modules/site_nagios/manifests')
-rw-r--r-- | puppet/modules/site_nagios/manifests/add_host.pp | 31 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/add_service.pp | 21 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/init.pp | 4 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/server.pp | 38 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/server/purge.pp | 7 |
5 files changed, 101 insertions, 0 deletions
diff --git a/puppet/modules/site_nagios/manifests/add_host.pp b/puppet/modules/site_nagios/manifests/add_host.pp new file mode 100644 index 00000000..498552b5 --- /dev/null +++ b/puppet/modules/site_nagios/manifests/add_host.pp @@ -0,0 +1,31 @@ +define site_nagios::add_host { + $nagios_host = $name + $nagios_hostname = $name['domain_internal'] + $nagios_ip = $name['ip_address'] + $nagios_services = $name['services'] + $nagios_openvpn_gw = $name['openvpn_gateway_address'] + + # Add Nagios host + nagios_host { $nagios_hostname: + address => $nagios_ip, + use => 'generic-host', + } + + # Add Nagios service + + # First, we need to turn the serice array into hash, using a "hash template" + # see https://github.com/ashak/puppet-resource-looping + $nagios_service_hashpart = { + 'hostname' => $nagios_hostname, + 'ip_address' => $nagios_ip, + 'openvpn_gw' => $nagios_openvpn_gw, + } + $dynamic_parameters = { + 'service' => '%s' + } + $nagios_servicename = "${nagios_hostname}_%s" + + $nagios_service_hash = create_resources_hash_from($nagios_servicename, $nagios_services, $nagios_service_hashpart, $dynamic_parameters) + + create_resources ( site_nagios::add_service, $nagios_service_hash ) +} diff --git a/puppet/modules/site_nagios/manifests/add_service.pp b/puppet/modules/site_nagios/manifests/add_service.pp new file mode 100644 index 00000000..6ef3cbf5 --- /dev/null +++ b/puppet/modules/site_nagios/manifests/add_service.pp @@ -0,0 +1,21 @@ +define site_nagios::add_service ( + $hostname, $ip_address, $openvpn_gw = '', $service) { + + case $service { + 'webapp': { + $check_command = 'check_https_cert' + $service_description = 'Website Certificate' + } + default: { + #notice ("No Nagios service check for service \"$service\"") + } + } + + if ( $check_command != '' ) { + nagios_service { $name: + use => 'generic-service', + check_command => $check_command, + service_description => $service_description, + host_name => $hostname } + } +} diff --git a/puppet/modules/site_nagios/manifests/init.pp b/puppet/modules/site_nagios/manifests/init.pp new file mode 100644 index 00000000..cab32905 --- /dev/null +++ b/puppet/modules/site_nagios/manifests/init.pp @@ -0,0 +1,4 @@ +class site_nagios { + tag 'leap_service' + include site_nagios::server +} diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp new file mode 100644 index 00000000..c98a8a1f --- /dev/null +++ b/puppet/modules/site_nagios/manifests/server.pp @@ -0,0 +1,38 @@ +class site_nagios::server inherits nagios::base { + + # First, purge old nagios config (see #1467) + class { 'site_nagios::server::purge': + stage => initial + } + + $nagios_hiera=hiera('nagios') + $nagiosadmin_pw = htpasswd_sha1($nagios_hiera['nagiosadmin_pw']) + $hosts = $nagios_hiera['hosts'] + + include nagios::defaults + include nagios::base + #Class ['nagios'] -> Class ['nagios::defaults'] + class {'nagios::apache': + allow_external_cmd => true, + stored_config => false, + #before => Class ['nagios::defaults'] + } + + File ['nagios_htpasswd'] { + source => undef, + content => "nagiosadmin:$nagiosadmin_pw", + mode => '0640', + } + + + # deploy serverside plugins + file { '/usr/lib/nagios/plugins/check_openvpn_server.pl': + source => 'puppet:///modules/nagios/plugins/check_openvpn_server.pl', + mode => '0755', + owner => 'nagios', + group => 'nagios', + } + + site_nagios::add_host {$hosts:} + include site_shorewall::monitor +} diff --git a/puppet/modules/site_nagios/manifests/server/purge.pp b/puppet/modules/site_nagios/manifests/server/purge.pp new file mode 100644 index 00000000..39735cd3 --- /dev/null +++ b/puppet/modules/site_nagios/manifests/server/purge.pp @@ -0,0 +1,7 @@ +class site_nagios::server::purge { + exec {'purge_conf.d': + command => '/bin/rm -rf /etc/nagios3/conf.d/*', + onlyif => 'test -e /etc/nagios3/conf.d' + } + +} |