diff --git a/manifests/nagios/objects/add_contact.pp b/manifests/nagios/objects/add_contact.pp
index 8bd69d5..7f6fbaf 100644
--- a/manifests/nagios/objects/add_contact.pp
+++ b/manifests/nagios/objects/add_contact.pp
@@ -21,6 +21,12 @@
# @summary Define manages additional contacts known to NAGIOS through external
# Puppet rules, and populates /etc/nagios/conf.d/nagios_add_contact.cfg.
# @example
+# cd_nagios::nagios::objects::add_contact { 'example_user':
+# ng_contact_name => 'example_user',
+# ng_contact_alias => 'Example User',
+# ng_contact_groups => 'admins',
+# ng_contact_email => 'example@example.net',
+# }
################################################################################
define cd_nagios::nagios::objects::add_contact (
diff --git a/manifests/nagios/objects/add_hostgroup_rules.pp b/manifests/nagios/objects/add_hostgroup_rules.pp
new file mode 100644
index 0000000..8f884a3
--- /dev/null
+++ b/manifests/nagios/objects/add_hostgroup_rules.pp
@@ -0,0 +1,64 @@
+## cd_nagios::nagios::objects::add_hostgroup_rules.pp
+# Module name: cd_nagios
+# Author: Arne Teuke (arne_teuke@ConfDroid.com)
+# # License:
+# This file is part of cd_nagios.
+#
+# cd_nagios is used for providing automatic configuration of Nagios
+# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+# @summary Class manages /etc/nagios_conf.d/nagios_hostgroups_add.cfg and
+# additional hostgroups through external Puppet rules via define.
+# @example
+# cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
+# ng_hostgroup_name => 'example_hostgroup',
+# ng_hostgroup_alias => 'Example Hostgroup',
+# }
+################################################################################
+class cd_nagios::nagios::objects::add_hostgroup_rules (
+
+
+) inherits cd_nagios::params {
+
+ if $::fqdn == $ng_nagios_server {
+
+ # manage /etc/nagios_conf.d/nagios_hostgroups_add.cfg
+
+ concat { $ng_tgt_hostgroup_add:
+ ensure => present,
+ path => $ng_tgt_hostgroup_add,
+ owner => $ng_user,
+ group => $ng_user,
+ mode => '0640',
+ selrange => s0,
+ selrole => object_r,
+ seltype => nagios_etc_t,
+ seluser => system_u,
+ notify => Service[$ng_service],
+ }
+
+ # manage file header
+
+ concat::fragment { 'hostgroups_header':
+ target => $ng_tgt_hostgroup_add,
+ content => template($ng_tgt_hostgrp_head_erb),
+ order => '000',
+ }
+
+ cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
+ ng_hostgroup_name => 'example_hostgroup',
+ ng_hostgroup_alias => 'Example Hostgroup',
+ }
+ }
+}
diff --git a/manifests/nagios/objects/add_hostgroups.pp b/manifests/nagios/objects/add_hostgroups.pp
new file mode 100644
index 0000000..58b2717
--- /dev/null
+++ b/manifests/nagios/objects/add_hostgroups.pp
@@ -0,0 +1,49 @@
+## cd_nagios::nagios::objects::add_hostgroups.pp
+# Module name: cd_nagios
+# Author: Arne Teuke (arne_teuke@ConfDroid.com)
+# # License:
+# This file is part of cd_nagios.
+#
+# cd_nagios is used for providing automatic configuration of Nagios
+# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# @summary define populates /etc/nagios/conf.d/nagios_hostgroups_add through
+# extermal Puppet rules.
+# @example
+# cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
+# ng_hostgroup_name => 'example_hostgroup',
+# ng_hostgroup_alias => 'Example Hostgroup',
+# }
+###############################################################################
+define cd_nagios::nagios::objects::add_hostgroups (
+
+$ng_hostgroup_name = undef,
+$ng_hostgroup_alias = undef,
+$ng_hostgroup_register = '1',
+
+) {
+
+$ng_nagios_server = $::cd_nagios::params::ng_nagios_server
+$ng_tgt_hostgroup_add = $::cd_nagios::params::ng_tgt_hostgroup_add
+$ng_tgt_hostgrp_head_erb = $::cd_nagios::params::ng_tgt_hostgrp_head_erb
+
+
+ if $::fqdn == $ng_nagios_server {
+
+ concat::fragment { $name:
+ target => $ng_tgt_hostgroup_add,
+ content => template($ng_tgt_hostgrp_head_erb),
+ }
+ }
+}
diff --git a/manifests/nagios/objects/config.pp b/manifests/nagios/objects/config.pp
index 82bf493..31713ce 100644
--- a/manifests/nagios/objects/config.pp
+++ b/manifests/nagios/objects/config.pp
@@ -33,6 +33,7 @@ class cd_nagios::nagios::objects::config (
require cd_nagios::nagios::objects::contactgroups
require cd_nagios::nagios::objects::add_contactgroups_rules
require cd_nagios::nagios::objects::hostgroups
+ require cd_nagios::nagios::objects::add_hostgroup_rules
}
}
diff --git a/manifests/nagios/objects/hostgroups.pp b/manifests/nagios/objects/hostgroups.pp
index 4c99d31..709f20b 100644
--- a/manifests/nagios/objects/hostgroups.pp
+++ b/manifests/nagios/objects/hostgroups.pp
@@ -38,7 +38,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
@@ -52,7 +52,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# CentOS servers
@@ -65,7 +65,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# SuSE servers
@@ -78,7 +78,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Unix servers
@@ -91,7 +91,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Solaris servers
@@ -104,7 +104,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# AIX servers
@@ -117,7 +117,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Windows servers
@@ -130,7 +130,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Netware servers
@@ -143,7 +143,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# DB servers
@@ -156,7 +156,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Oracle servers
@@ -169,7 +169,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# MySQL servers
@@ -182,7 +182,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# MSSQL servers
@@ -195,7 +195,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# NOSQL servers
@@ -208,7 +208,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
# Hadoop servers
@@ -221,7 +221,7 @@ class cd_nagios::nagios::objects::hostgroups (
group => $ng_user,
mode => '0640',
register => '1',
- target => $ng_target_hostgroup,
+ target => $ng_target_hostgroup_base,
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
index c0396fd..5f1a066 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -965,7 +965,9 @@ $ng_templates_rule_erb = 'cd_nagios/nagios/templates_cfg_rule.erb'
$ng_target_timeperiods = "${ng_conf_d_dir}/timeperiods.cfg"
$ng_target_localhost = "${ng_conf_d_dir}/nagios_localhost.cfg"
$ng_target_host = "${ng_conf_d_dir}/nagios_host.cfg"
-$ng_target_hostgroup = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
+$ng_target_hostgroup_base = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
+$ng_tgt_hostgroup_add = "${ng_conf_d_dir}/nagios_hostgroups_add.cfg"
+$ng_tgt_hostgrp_head_erb = 'cd_nagios/nagios/hostgroups_cfg_head.erb'
$ng_target_hostdep = "${ng_conf_d_dir}/nagios_hostdependency.cfg"
$ng_target_hostesc = "${ng_conf_d_dir}/nagios_hostescalation.cfg"
$ng_target_hostext = "${ng_conf_d_dir}/nagios_hostextinfo.cfg"
diff --git a/manifests/server/service.pp b/manifests/server/service.pp
index c734c59..95a7106 100644
--- a/manifests/server/service.pp
+++ b/manifests/server/service.pp
@@ -42,11 +42,12 @@ class cd_nagios::server::service (
use => 'generic-service',
host_name => $::fqdn,
notification_period => '24x7',
+ service_description => "${::hostname}_nagios_service",
target => $ng_target_service,
owner => 'nagios',
group => 'nagios',
- mode => '660',
- contacts => 'DevOps',
+ mode => '0660',
+ contacts => 'ops',
}
resources { [ 'nagios_host',
diff --git a/templates/nagios/hostgroups_cfg_head.erb b/templates/nagios/hostgroups_cfg_head.erb
new file mode 100644
index 0000000..acfbb87
--- /dev/null
+++ b/templates/nagios/hostgroups_cfg_head.erb
@@ -0,0 +1,5 @@
+###############################################################################
+########## nagios_hostgroups_add.cfg created by Puppet ##########
+########## manual changes are overwritten! ##########
+###############################################################################
+# rules are created below by external puppet rules.
diff --git a/templates/nagios/hostgroups_cfg_rule.erb b/templates/nagios/hostgroups_cfg_rule.erb
new file mode 100644
index 0000000..70b27e3
--- /dev/null
+++ b/templates/nagios/hostgroups_cfg_rule.erb
@@ -0,0 +1,6 @@
+
+define hostgroup {
+ hostgroup_name <%= @ng_hostgroup_name %>
+ alias <%= @ng_hostgroup_alias %>
+ register <%= @ng_hostgroup_register %>
+ }