added and linked hostgroups

This commit is contained in:
Arne Teuke
2017-07-27 12:44:19 +01:00
parent 3f12bbd92d
commit 7b27896ccb
6 changed files with 234 additions and 2 deletions

View File

@@ -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)

View File

@@ -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
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
# @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,
}
}
}

View File

@@ -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

View File

@@ -1,3 +1,4 @@
define contactgroup {
contactgroup_name <%= @ng_contactgroup_name %>
alias <%= @ng_contactgroup_alias %>

View File

@@ -1,3 +1,4 @@
define contact {
contact_name <%= @ng_contact_name %>
use <%= @ng_contact_use %>