diff --git a/README.md b/README.md index 5aa0913..3b3f7ab 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Configuration * manage Nagios template definitions through external Puppet rules via define * manage Nagios main contacts through Puppet exports. Additional contacts can be created through external Puppet rules via define, to avoid having to alter the module code. * manage Nagios main contactgroups through Puppet exports. Additional contact groups can be created through external Puppet rules via define, to avoid having to alter the module code. +* manage Nagios main hostgroups through Puppet exports. Additional host groups can be created through external Puppet rules via define, to avoid having to alter the module code. * configure NRPE on clients (optional) * configure firewall (optional) * configure selinux policies (optional) diff --git a/manifests/nagios/objects/config.pp b/manifests/nagios/objects/config.pp index e9a0922..82bf493 100644 --- a/manifests/nagios/objects/config.pp +++ b/manifests/nagios/objects/config.pp @@ -32,6 +32,7 @@ class cd_nagios::nagios::objects::config ( require cd_nagios::nagios::objects::add_contact_rules require cd_nagios::nagios::objects::contactgroups require cd_nagios::nagios::objects::add_contactgroups_rules + require cd_nagios::nagios::objects::hostgroups } } diff --git a/manifests/nagios/objects/hostgroups.pp b/manifests/nagios/objects/hostgroups.pp new file mode 100644 index 0000000..4c99d31 --- /dev/null +++ b/manifests/nagios/objects/hostgroups.pp @@ -0,0 +1,228 @@ +## cd_nagios::nagios::objects::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 Class manages basic hostgroups known to NAGIOS through Puppet +# exports, and populates /etc/nagios/conf.d/nagios_base_hostgroups.cfg. +################################################################################ +class cd_nagios::nagios::objects::hostgroups ( + + +) inherits cd_nagios::params { + + if $::fqdn == $ng_nagios_server { + + # linux servers + + @@nagios_hostgroup { 'linux-servers': + ensure => present, + hostgroup_name => 'linux-servers', + alias => 'Linux Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + + # RHEL servers + + @@nagios_hostgroup { 'rhel-servers': + ensure => present, + hostgroup_name => 'rhel-servers', + alias => 'RHEL Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # CentOS servers + + @@nagios_hostgroup { 'centos-servers': + ensure => present, + hostgroup_name => 'centos-servers', + alias => 'CentOS Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # SuSE servers + + @@nagios_hostgroup { 'suse-servers': + ensure => present, + hostgroup_name => 'suse-servers', + alias => 'SuSE Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Unix servers + + @@nagios_hostgroup { 'unix-servers': + ensure => present, + hostgroup_name => 'unix-servers', + alias => 'Unix Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Solaris servers + + @@nagios_hostgroup { 'solaris-servers': + ensure => present, + hostgroup_name => 'solaris-servers', + alias => 'Solaris Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # AIX servers + + @@nagios_hostgroup { 'aix-servers': + ensure => present, + hostgroup_name => 'aix-servers', + alias => 'AIX Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Windows servers + + @@nagios_hostgroup { 'windows-servers': + ensure => present, + hostgroup_name => 'windows-servers', + alias => 'Windows Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Netware servers + + @@nagios_hostgroup { 'netware-servers': + ensure => present, + hostgroup_name => 'netware-servers', + alias => 'Netware Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # DB servers + + @@nagios_hostgroup { 'db-servers': + ensure => present, + hostgroup_name => 'db-servers', + alias => 'DB Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Oracle servers + + @@nagios_hostgroup { 'oracle-servers': + ensure => present, + hostgroup_name => 'oracle-servers', + alias => 'Oracle Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # MySQL servers + + @@nagios_hostgroup { 'mysql-servers': + ensure => present, + hostgroup_name => 'mysql-servers', + alias => 'MySQL Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # MSSQL servers + + @@nagios_hostgroup { 'mssql-servers': + ensure => present, + hostgroup_name => 'mssql-servers', + alias => 'MSSQL Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # NOSQL servers + + @@nagios_hostgroup { 'nosql-servers': + ensure => present, + hostgroup_name => 'nosql-servers', + alias => 'NOSQL Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + # Hadoop servers + + @@nagios_hostgroup { 'hadoop-servers': + ensure => present, + hostgroup_name => 'hadoop-servers', + alias => 'HADOOP Servers', + owner => $ng_user, + group => $ng_user, + mode => '0640', + register => '1', + target => $ng_target_hostgroup, + } + + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 1589b8a..c0396fd 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -965,7 +965,7 @@ $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_hostgroup.cfg" +$ng_target_hostgroup = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg" $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" @@ -979,7 +979,7 @@ $ng_tgt_contactgroup_base = "${ng_conf_d_dir}/nagios_contactgroup_base.cfg" $ng_tgt_contactgroup_add = "${ng_conf_d_dir}/nagios_contactgroup_add.cfg" $ng_cntctgrps_head_erb = 'cd_nagios/nagios/contactgroups_cfg_head.erb' $ng_cntctgrps_rule_erb = 'cd_nagios/nagios/contactgroups_cfg_rule.erb' -$ng_target_command = "${ng_conf_d_dir}/nagios_command.cfg" +$ng_target_command = "${ng_conf_d_dir}/nagios_commands_base.cfg" # includes must be last diff --git a/templates/nagios/contactgroups_cfg_rule.erb b/templates/nagios/contactgroups_cfg_rule.erb index f4bbd98..a3c7d4c 100644 --- a/templates/nagios/contactgroups_cfg_rule.erb +++ b/templates/nagios/contactgroups_cfg_rule.erb @@ -1,3 +1,4 @@ + define contactgroup { contactgroup_name <%= @ng_contactgroup_name %> alias <%= @ng_contactgroup_alias %> diff --git a/templates/nagios/contacts_cfg_rule.erb b/templates/nagios/contacts_cfg_rule.erb index 6f103fa..356fa67 100644 --- a/templates/nagios/contacts_cfg_rule.erb +++ b/templates/nagios/contacts_cfg_rule.erb @@ -1,3 +1,4 @@ + define contact { contact_name <%= @ng_contact_name %> use <%= @ng_contact_use %>