added and linked add_contactgroups_rules

This commit is contained in:
Arne Teuke
2017-07-27 11:39:45 +01:00
parent 5108aab0dc
commit 26ef9aac81
6 changed files with 92 additions and 4 deletions

View File

@@ -23,15 +23,21 @@
################################################################################
define cd_nagios::nagios::objects::add_contactgroups (
$ng_contactgroup_name = undef,
$ng_contactgroup_alias = undef,
$ng_contactgroup_register = '1',
) {
$ng_nagios_server == $::cd_nagios::params::ng_nagios_server
$ng_nagios_server = $::cd_nagios::params::ng_nagios_server
$ng_tgt_contactgroup_add = $::cd_nagios::params::ng_tgt_contactgroup_add
if $::fqdn == $ng_nagios_server {
concat::fragment { $name:
target => $ng_tgt_contactgroup_add,
content => template($ng_contacts_rule_erb),
}
}
}

View File

@@ -0,0 +1,66 @@
## cd_nagios::nagios::objects::add_contactgroups_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 <http://www.gnu.org/licenses/>.
# @summary Class manages /etc/nagios/conf.d/nagios_add_contactgroups.cfg file
# and populates through define and external puppet rules
# @example
# cd_nagios::nagios::objects::add_contactgroups { 'example_group':
# ng_contactgroup_name => 'example_group',
# ng_contactgroup_alias => 'Example Group',
# ng_contactgroup_register '1',
# }
################################################################################
class cd_nagios::nagios::objects::add_contactgroups_rules (
) inherits cd_nagios::params {
if $::fqdn == $ng_nagios_server {
# manage /etc/nagios/conf.d/nagios_add_contactgroups.cfg
concat { $ng_tgt_contactgroup_add:
ensure => present,
path => $ng_tgt_contactgroup_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 { 'contactgroups_header':
target => $ng_tgt_contactgroup_add,
content => template($ng_cntctgrps_head_erb),
order => '000',
}
cd_nagios::nagios::objects::add_contactgroups { 'example_group':
ng_contactgroup_name => 'example_group',
ng_contactgroup_alias => 'Example Group',
ng_contactgroup_register '1',
}
}
}

View File

@@ -976,6 +976,9 @@ $ng_target_add_contact = "${ng_conf_d_dir}/nagios_add_contact.cfg"
$ng_contacts_head_erb = 'cd_nagios/nagios/contacts_cfg_head.erb'
$ng_contacts_rule_erb = 'cd_nagios/nagios/contacts_cfg_rule.erb'
$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"

View File

@@ -0,0 +1,8 @@
###############################################################################
########## nagios_add_contactgroups.cfg created by Puppet ##########
########## manual changes are overwritten! ##########
###############################################################################
########## Full reference file available at ##########
########## https://confdroid.com/2017/07/nagios-contacts-cfg/ ##########
###############################################################################
# rules are created below by external puppet rules.

View File

@@ -0,0 +1,5 @@
define contactgroup {
contactgroup_name <%= @ng_contactgroup_name %>
alias <%= @ng_contactgroup_alias %>
register <%= @ng_contactgroup_register %>
}