summaryrefslogtreecommitdiff
path: root/puppet/modules
diff options
context:
space:
mode:
authorMicah Anderson <micah@leap.se>2014-12-02 11:26:35 -0500
committerMicah Anderson <micah@leap.se>2014-12-02 22:58:13 -0500
commita84272aa77715a4029ebd06b38b7a5ad05e6acd0 (patch)
treecd4d4c165ced4ec283fbeab0071daaf735c2be51 /puppet/modules
parenta3af7019efe6f5ff3daeeff474a8c31b1b3318c8 (diff)
Change nagios mail To: Header to contain the actual platform environment's contact email (Bug #6466)
Change-Id: Ib86ae771e0ac3b6f329a517a8a31c9ec54d33a05
Diffstat (limited to 'puppet/modules')
-rw-r--r--puppet/modules/site_check_mk/files/host_contactgroups.mk3
-rw-r--r--puppet/modules/site_check_mk/manifests/server.pp3
-rw-r--r--puppet/modules/site_check_mk/templates/host_contactgroups.mk17
-rw-r--r--puppet/modules/site_check_mk/templates/hostgroups.mk17
-rw-r--r--puppet/modules/site_nagios/manifests/add_host_services.pp5
-rw-r--r--puppet/modules/site_nagios/manifests/add_service.pp11
-rw-r--r--puppet/modules/site_nagios/manifests/server.pp9
-rw-r--r--puppet/modules/site_nagios/manifests/server/add_contacts.pp16
-rw-r--r--puppet/modules/site_nagios/manifests/server/contactgroup.pp6
-rw-r--r--puppet/modules/site_nagios/manifests/server/hostgroup.pp2
10 files changed, 73 insertions, 16 deletions
diff --git a/puppet/modules/site_check_mk/files/host_contactgroups.mk b/puppet/modules/site_check_mk/files/host_contactgroups.mk
deleted file mode 100644
index e89323fb..00000000
--- a/puppet/modules/site_check_mk/files/host_contactgroups.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-host_contactgroups = [
- ( "admins", ALL_HOSTS ),
-]
diff --git a/puppet/modules/site_check_mk/manifests/server.pp b/puppet/modules/site_check_mk/manifests/server.pp
index b384923c..1a866b9c 100644
--- a/puppet/modules/site_check_mk/manifests/server.pp
+++ b/puppet/modules/site_check_mk/manifests/server.pp
@@ -11,6 +11,7 @@ class site_check_mk::server {
$hosts = hiera_hash('hosts')
$all_hosts = inline_template ('<% @hosts.keys.sort.each do |key| -%>"<%= @hosts[key]["domain_internal"] %>", <% end -%>')
$domains_internal = $nagios_hiera['domains_internal']
+ $environments = $nagios_hiera['environments']
package { 'check-mk-server':
ensure => installed,
@@ -41,7 +42,7 @@ class site_check_mk::server {
notify => Exec['check_mk-refresh'],
require => Package['check-mk-server'];
'/etc/check_mk/conf.d/host_contactgroups.mk':
- source => 'puppet:///modules/site_check_mk/host_contactgroups.mk',
+ content => template('site_check_mk/host_contactgroups.mk'),
notify => Exec['check_mk-refresh'],
require => Package['check-mk-server'];
'/etc/check_mk/conf.d/ignored_services.mk':
diff --git a/puppet/modules/site_check_mk/templates/host_contactgroups.mk b/puppet/modules/site_check_mk/templates/host_contactgroups.mk
new file mode 100644
index 00000000..6a534967
--- /dev/null
+++ b/puppet/modules/site_check_mk/templates/host_contactgroups.mk
@@ -0,0 +1,17 @@
+<%
+ contact_groups = []
+ @environments.keys.sort.each do |env_name|
+ hosts = ""
+ @nagios_hosts.keys.sort.each do |hostname|
+ hostdata = @nagios_hosts[hostname]
+ domain_internal = hostdata['domain_internal']
+ if hostdata['environment'] == env_name
+ hosts << '"' + domain_internal + '", '
+ end
+ end
+ contact_groups << ' ( "%s", [%s] )' % [env_name, hosts]
+ end
+%>
+host_contactgroups = [
+<%= contact_groups.join(",\n") %>
+]
diff --git a/puppet/modules/site_check_mk/templates/hostgroups.mk b/puppet/modules/site_check_mk/templates/hostgroups.mk
index 79b7f92f..7158dcd1 100644
--- a/puppet/modules/site_check_mk/templates/hostgroups.mk
+++ b/puppet/modules/site_check_mk/templates/hostgroups.mk
@@ -1,4 +1,17 @@
+<%
+ host_groups = []
+ @environments.keys.sort.each do |env_name|
+ hosts = ""
+ @nagios_hosts.keys.sort.each do |hostname|
+ hostdata = @nagios_hosts[hostname]
+ domain_internal = hostdata['domain_internal']
+ if hostdata['environment'] == env_name
+ hosts << '"' + domain_internal + '", '
+ end
+ end
+ host_groups << ' ( "%s", [%s] )' % [env_name, hosts]
+ end
+%>
host_groups = [
- <% @domains_internal.each do |domain| %>( '<%= domain %>', [<% @nagios_hosts.keys.sort.each do |key| -%><% if @nagios_hosts[key]['domain_internal'] == key+'.'+domain -%>'<%= key %>.<%= domain %>', <% end -%><% end -%>] ),
- <% end -%>
+<%= host_groups.join(",\n") %>
]
diff --git a/puppet/modules/site_nagios/manifests/add_host_services.pp b/puppet/modules/site_nagios/manifests/add_host_services.pp
index 279809d1..236702e2 100644
--- a/puppet/modules/site_nagios/manifests/add_host_services.pp
+++ b/puppet/modules/site_nagios/manifests/add_host_services.pp
@@ -4,7 +4,9 @@ define site_nagios::add_host_services (
$ip_address,
$services,
$ssh_port,
- $openvpn_gateway_address='' ) {
+ $environment,
+ $openvpn_gateway_address='',
+ ) {
$nagios_hostname = $domain_internal
@@ -16,6 +18,7 @@ define site_nagios::add_host_services (
'hostname' => $nagios_hostname,
'ip_address' => $ip_address,
'openvpn_gw' => $openvpn_gateway_address,
+ 'environment' => $environment
}
$dynamic_parameters = {
'service' => '%s'
diff --git a/puppet/modules/site_nagios/manifests/add_service.pp b/puppet/modules/site_nagios/manifests/add_service.pp
index 97c0b30d..72cd038a 100644
--- a/puppet/modules/site_nagios/manifests/add_service.pp
+++ b/puppet/modules/site_nagios/manifests/add_service.pp
@@ -1,5 +1,5 @@
define site_nagios::add_service (
- $hostname, $ip_address, $openvpn_gw = '', $service) {
+ $hostname, $ip_address, $service, $environment, $openvpn_gw = '') {
$ssh = hiera_hash('ssh')
$ssh_port = $ssh['port']
@@ -11,17 +11,20 @@ define site_nagios::add_service (
use => 'generic-service',
check_command => "check_ssh_port!${ssh_port}",
service_description => 'SSH',
- host_name => $hostname;
+ host_name => $hostname,
+ contact_groups => $environment;
"${name}_cert":
use => 'generic-service',
check_command => 'check_https_cert',
service_description => 'Website Certificate',
- host_name => $hostname;
+ host_name => $hostname,
+ contact_groups => $environment;
"${name}_website":
use => 'generic-service',
check_command => 'check_https',
service_description => 'Website',
- host_name => $hostname
+ host_name => $hostname,
+ contact_groups => $environment;
}
}
default: {}
diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp
index 37bd77fb..068ee419 100644
--- a/puppet/modules/site_nagios/manifests/server.pp
+++ b/puppet/modules/site_nagios/manifests/server.pp
@@ -6,12 +6,11 @@ class site_nagios::server inherits nagios::base {
$nagios_hiera = hiera('nagios')
$nagiosadmin_pw = htpasswd_sha1($nagios_hiera['nagiosadmin_pw'])
$nagios_hosts = $nagios_hiera['hosts']
- $domains_internal = $nagios_hiera['domains_internal']
+ $nagios_contacts = hiera('contacts')
+ $environment = $nagios_hiera['environments']
include nagios::base
include nagios::defaults::commands
- include nagios::defaults::contactgroups
- include nagios::defaults::contacts
include nagios::defaults::templates
include nagios::defaults::timeperiods
include nagios::defaults::plugins
@@ -63,5 +62,7 @@ class site_nagios::server inherits nagios::base {
'set copytruncate copytruncate' ]
}
- ::site_nagios::server::hostgroup { $domains_internal: }
+ create_resources ( site_nagios::server::hostgroup, $environment )
+ create_resources ( site_nagios::server::contactgroup, $environment )
+ create_resources ( site_nagios::server::add_contacts, $environment )
}
diff --git a/puppet/modules/site_nagios/manifests/server/add_contacts.pp b/puppet/modules/site_nagios/manifests/server/add_contacts.pp
new file mode 100644
index 00000000..db507abf
--- /dev/null
+++ b/puppet/modules/site_nagios/manifests/server/add_contacts.pp
@@ -0,0 +1,16 @@
+define site_nagios::server::add_contacts ($contact_emails) {
+
+ $environment = $name
+
+ nagios_contact {
+ $environment:
+ alias => $environment,
+ service_notification_period => '24x7',
+ host_notification_period => '24x7',
+ service_notification_options => 'w,u,c,r',
+ host_notification_options => 'd,r',
+ service_notification_commands => 'notify-service-by-email',
+ host_notification_commands => 'notify-host-by-email',
+ email => join($contact_emails, ', ')
+ }
+}
diff --git a/puppet/modules/site_nagios/manifests/server/contactgroup.pp b/puppet/modules/site_nagios/manifests/server/contactgroup.pp
new file mode 100644
index 00000000..188c54f1
--- /dev/null
+++ b/puppet/modules/site_nagios/manifests/server/contactgroup.pp
@@ -0,0 +1,6 @@
+define site_nagios::server::contactgroup ($contact_emails) {
+
+ nagios_contactgroup { $name:
+ members => $name
+ }
+}
diff --git a/puppet/modules/site_nagios/manifests/server/hostgroup.pp b/puppet/modules/site_nagios/manifests/server/hostgroup.pp
index 035ba7d1..6f85ca6d 100644
--- a/puppet/modules/site_nagios/manifests/server/hostgroup.pp
+++ b/puppet/modules/site_nagios/manifests/server/hostgroup.pp
@@ -1,3 +1,3 @@
-define site_nagios::server::hostgroup {
+define site_nagios::server::hostgroup ($contact_emails) {
nagios_hostgroup { $name: }
}