added and linked add_timeperiods
This commit is contained in:
@@ -53,6 +53,7 @@ Configuration
|
|||||||
* 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 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.
|
* 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.
|
||||||
* manage Nagios main servicegroups through Puppet exports. Additional service groups can be created through external Puppet rules via define, to avoid having to alter the module code.
|
* manage Nagios main servicegroups through Puppet exports. Additional service groups can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||||
|
* manage Nagios main timeperiods through Puppet exports. Additional timeperiods can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||||
* configure NRPE on clients (optional)
|
* configure NRPE on clients (optional)
|
||||||
* configure firewall (optional)
|
* configure firewall (optional)
|
||||||
* configure selinux policies (optional)
|
* configure selinux policies (optional)
|
||||||
|
|||||||
77
manifests/nagios/objects/add_timeperiod_rules.pp
Normal file
77
manifests/nagios/objects/add_timeperiod_rules.pp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# cd_nagios::nagios::objects::add_timeperiod_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_timeperiods_add.cfg. incl.
|
||||||
|
# additional timeperiods via define.
|
||||||
|
# cd_nagios::nagios::objects::add_timeperiods { 'example_timeperiod':
|
||||||
|
# ng_timeperiod_name => 'example_timeperiod',
|
||||||
|
# ng_timeperiod_alias => 'Example timeperiod',
|
||||||
|
# ng_timep_monday => '00:00-00:00',
|
||||||
|
# ng_timep_tuesday => '00:00-00:00',
|
||||||
|
# ng_timep_wednesday => '00:00-00:00',
|
||||||
|
# ng_timep_thursday => '00:00-00:00',
|
||||||
|
# ng_timep_friday => '00:00-00:00',
|
||||||
|
# ng_timep_saturday => '00:00-00:00',
|
||||||
|
# ng_timep_sunday => '00:00-00:00',
|
||||||
|
# }
|
||||||
|
################################################################################
|
||||||
|
class cd_nagios::nagios::objects::add_timeperiod_rules (
|
||||||
|
|
||||||
|
) inherits cd_nagios::params {
|
||||||
|
|
||||||
|
if $::fqdn == $ng_nagios_server {
|
||||||
|
|
||||||
|
# manage /etc/nagios/conf.d/nagios_timeperiods_add.cfg
|
||||||
|
|
||||||
|
concat { $ng_tgt_timeperiods_add:
|
||||||
|
ensure => present,
|
||||||
|
path => $ng_tgt_timeperiods_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 { 'timeperiods_header':
|
||||||
|
target => $ng_tgt_timeperiods_add,
|
||||||
|
content => template($ng_tgt_timep_head_erb),
|
||||||
|
order => '000',
|
||||||
|
}
|
||||||
|
|
||||||
|
# example rule
|
||||||
|
cd_nagios::nagios::objects::add_timeperiods { 'example_timeperiod':
|
||||||
|
ng_timeperiod_name => 'example_timeperiod',
|
||||||
|
ng_timeperiod_alias => 'Example timeperiod',
|
||||||
|
ng_timep_monday => '00:00-00:00',
|
||||||
|
ng_timep_tuesday => '00:00-00:00',
|
||||||
|
ng_timep_wednesday => '00:00-00:00',
|
||||||
|
ng_timep_thursday => '00:00-00:00',
|
||||||
|
ng_timep_friday => '00:00-00:00',
|
||||||
|
ng_timep_saturday => '00:00-00:00',
|
||||||
|
ng_timep_sunday => '00:00-00:00',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
manifests/nagios/objects/add_timeperiods.pp
Normal file
69
manifests/nagios/objects/add_timeperiods.pp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
## cd_nagios::nagios::objects::add_timeperiods.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 define populates /etc/nagios/conf.d/nagios_timeperiods_add through
|
||||||
|
# extermal Puppet rules.
|
||||||
|
# @example
|
||||||
|
# cd_nagios::nagios::objects::add_timeperiods { 'example_timeperiod':
|
||||||
|
# ng_timeperiod_name => 'example_timeperiod',
|
||||||
|
# ng_timeperiod_alias => 'Example timeperiod',
|
||||||
|
# }
|
||||||
|
# @param [string] ng_timep_name Specify the timeperiod short name.
|
||||||
|
# @param [string] ng_timep_alias Specify the timeperiod alias (long name)
|
||||||
|
# @param [string] ng_timep_monday Specify the desired hours for Monday
|
||||||
|
# @param [string] ng_timep_tuesday Specify the desired hours for Tuesday
|
||||||
|
# @param [string] ng_timep_wednesday Specify the desired hours for Wednesday.
|
||||||
|
# @param [string] ng_timep_thursday Specify the desired hours for Thursday
|
||||||
|
# @param [string] ng_timep_friday Specify the desired hours for Friday
|
||||||
|
# @param [string] ng_timep_saturday Specify the desired hours for Saturday
|
||||||
|
# @param [string] ng_timep_sunday Specify the desired hours for Sunday.
|
||||||
|
# @param [string] ng_timep_special_01 Specify a special date as key parameter
|
||||||
|
# for `ng_timep_special_02`. See Nagios documentation for format details.
|
||||||
|
# @param [string] ng_timep_special_02 Specify desired hours as value parameter
|
||||||
|
# for `g_timep_special_01`.
|
||||||
|
###############################################################################
|
||||||
|
define cd_nagios::nagios::objects::add_timeperiods (
|
||||||
|
|
||||||
|
$ng_timep_name = undef,
|
||||||
|
$ng_timep_alias = undef,
|
||||||
|
$ng_timep_monday = '00:00-00:00',
|
||||||
|
$ng_timep_tuesday = '00:00-00:00',
|
||||||
|
$ng_timep_wednesday = '00:00-00:00',
|
||||||
|
$ng_timep_thursday = '00:00-00:00',
|
||||||
|
$ng_timep_friday = '00:00-00:00',
|
||||||
|
$ng_timep_saturday = '00:00-00:00',
|
||||||
|
$ng_timep_sunday = '00:00-00:00',
|
||||||
|
$ng_timep_special_01 = undef,
|
||||||
|
$ng_timep_special_02 = '00:00-00:00',
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
$ng_nagios_server = $::cd_nagios::params::ng_nagios_server
|
||||||
|
$ng_tgt_timep_add = $::cd_nagios::params::ng_tgt_timeperiod_add
|
||||||
|
$ng_tgt_timep_rule_erb = $::cd_nagios::params::ng_tgt_timep_rule_erb
|
||||||
|
|
||||||
|
if $::fqdn == $ng_nagios_server {
|
||||||
|
|
||||||
|
concat::fragment { $name:
|
||||||
|
target => $ng_tgt_timep_add,
|
||||||
|
content => template($ng_tgt_timep_rule_erb),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,6 @@ class cd_nagios::nagios::objects::config (
|
|||||||
require cd_nagios::nagios::objects::servicegroups
|
require cd_nagios::nagios::objects::servicegroups
|
||||||
require cd_nagios::nagios::objects::add_servicegroup_rules
|
require cd_nagios::nagios::objects::add_servicegroup_rules
|
||||||
require cd_nagios::nagios::objects::timeperiods
|
require cd_nagios::nagios::objects::timeperiods
|
||||||
|
require cd_nagios::nagios::objects::add_timeperiod_rules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# @summary Class manages all timeperiods for NAGIOS through Puppet exports,
|
# @summary Class manages main timeperiods for NAGIOS through Puppet exports,
|
||||||
# and populates /etc/nagios/conf.d/nagios_timeperiods.cfg.
|
# and populates /etc/nagios/conf.d/nagios_timeperiods_base.cfg.
|
||||||
################################################################################
|
################################################################################
|
||||||
class cd_nagios::nagios::objects::timeperiods (
|
class cd_nagios::nagios::objects::timeperiods (
|
||||||
|
|
||||||
@@ -54,6 +54,8 @@ class cd_nagios::nagios::objects::timeperiods (
|
|||||||
wednesday => '09:00-17:00',
|
wednesday => '09:00-17:00',
|
||||||
thursday => '09:00-17:00',
|
thursday => '09:00-17:00',
|
||||||
friday => '09:00-17:00',
|
friday => '09:00-17:00',
|
||||||
|
saturday => '00:00-00:00',
|
||||||
|
sunday => '00:00-00:00',
|
||||||
owner => $ng_user,
|
owner => $ng_user,
|
||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
@@ -78,5 +80,16 @@ class cd_nagios::nagios::objects::timeperiods (
|
|||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_tgt_timeperiods_base,
|
target => $ng_tgt_timeperiods_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@nagios_timeperiod { 'none':
|
||||||
|
ensure => present,
|
||||||
|
timeperiod_name => 'none',
|
||||||
|
alias => 'No Time Is A Good Time',
|
||||||
|
owner => $ng_user,
|
||||||
|
group => $ng_user,
|
||||||
|
mode => '0640',
|
||||||
|
register => '1',
|
||||||
|
target => $ng_tgt_timeperiods_base,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -964,7 +964,10 @@ $ng_certbot_live = "${ng_certbot_main_dir}/live"
|
|||||||
$ng_target_templates = "${ng_conf_d_dir}/nagios_templates.cfg"
|
$ng_target_templates = "${ng_conf_d_dir}/nagios_templates.cfg"
|
||||||
$ng_templates_head_erb = 'cd_nagios/nagios/templates_cfg_head.erb'
|
$ng_templates_head_erb = 'cd_nagios/nagios/templates_cfg_head.erb'
|
||||||
$ng_templates_rule_erb = 'cd_nagios/nagios/templates_cfg_rule.erb'
|
$ng_templates_rule_erb = 'cd_nagios/nagios/templates_cfg_rule.erb'
|
||||||
$ng_tgt_timeperiods_base = "${ng_conf_d_dir}/timeperiods.cfg"
|
$ng_tgt_timeperiods_base = "${ng_conf_d_dir}/nagios_timeperiods.cfg"
|
||||||
|
$ng_tgt_timeperiods_add = "${ng_conf_d_dir}/nagios_timeperiods_add.cfg"
|
||||||
|
$ng_tgt_timep_head_erb = 'cd_nagios/nagios/timeperiods_cfg_head.erb'
|
||||||
|
$ng_tgt_timep_rule_erb = 'cd_nagios/nagios/timeperiods_cfg_rule.erb'
|
||||||
$ng_target_localhost = "${ng_conf_d_dir}/nagios_localhost.cfg"
|
$ng_target_localhost = "${ng_conf_d_dir}/nagios_localhost.cfg"
|
||||||
$ng_target_host = "${ng_conf_d_dir}/nagios_host.cfg"
|
$ng_target_host = "${ng_conf_d_dir}/nagios_host.cfg"
|
||||||
$ng_target_hostgroup_base = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
|
$ng_target_hostgroup_base = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
|
||||||
|
|||||||
5
templates/nagios/timeperiods_cfg_head.erb
Normal file
5
templates/nagios/timeperiods_cfg_head.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
###############################################################################
|
||||||
|
########## nagios_timeperiods_add.cfg created by Puppet ##########
|
||||||
|
########## manual changes are overwritten! ##########
|
||||||
|
###############################################################################
|
||||||
|
# rules are created below by external puppet rules.
|
||||||
18
templates/nagios/timeperiods_cfg_rule.erb
Normal file
18
templates/nagios/timeperiods_cfg_rule.erb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
define timeperiod {
|
||||||
|
timeperiod_name <%= @ng_timeperiod_name %>
|
||||||
|
alias <%= @ng_timeperiod_alias %>
|
||||||
|
monday <%= @ng_timep_monday %>
|
||||||
|
tuesday <%= @ng_timep_tuesday %>
|
||||||
|
wednesday <%= @ng_timep_wednesday %>
|
||||||
|
thursday <%= @ng_timep_thursday %>
|
||||||
|
friday <%= @ng_timep_friday %>
|
||||||
|
saturday <%= @ng_timep_saturday %>
|
||||||
|
sunday <%= @ng_timep_sunday %>
|
||||||
|
}
|
||||||
|
<% unless @ng_timep_special_01.empty? -%>
|
||||||
|
define timeperiod {
|
||||||
|
timeperiod_name <%= @ng_timeperiod_name %>
|
||||||
|
@ng_timep_special_01
|
||||||
|
}
|
||||||
|
<% end -%>
|
||||||
Reference in New Issue
Block a user