Files
confdroid_nagios/manifests/server/service.pp
2017-07-27 13:46:46 +01:00

105 lines
4.2 KiB
Puppet

## cd_nagios::server::service.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 the service(s) for cd_nagios.
#############################################################################
class cd_nagios::server::service (
) inherits cd_nagios::params {
if $::fqdn == $ng_nagios_server {
require cd_nagios::server::files
require cd_nagios::server::access_rules
require cd_nagios::nagios::objects::config
service { $ng_service:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
}
@@nagios_host { 'localhost':
ensure => $ng_ping_ensure,
alias => 'localhost',
address => '127.0.0.1',
use => 'linux-server',
target => $ng_target_localhost,
hostgroups => 'linux-servers',
contacts => 'ops',
max_check_attempts => $max_check_attempts,
notification_period => '24x7',
owner => $ng_user,
group => $ng_user,
mode => '0640',
check_command => "check_ping!${ng_ping_warn}!${ng_ping_crit}",
notify => Service ['nagios'],
}
@@nagios_service { "check_nagios_localhost":
check_command => 'check_nagios!/var/log/nagios/status.dat!5!/usr/sbin/nagios',
use => 'generic-service',
host_name => 'localhost',
notification_period => '24x7',
service_description => 'localhost_nagios_service',
target => $ng_target_service,
owner => $ng_user,
group => $ng_user,
mode => '0640',
contacts => 'ops',
}
resources { [ 'nagios_host',
'nagios_hostgroup',
'nagios_hostdependency',
'nagios_hostescalation',
'nagios_hostextinfo',
'nagios_service',
'nagios_servicegroup',
'nagios_servicedependency',
'nagios_serviceescalation',
'nagios_serviceextinfo',
'nagios_contact',
'nagios_contactgroup',
'nagios_command',
'nagios_timeperiod' ]:
purge => true,
}
# collect resources and populate /etc/nagios/conf.d/nagios_*.cfg
Nagios_host <<||>> { notify => Service['nagios'] }
Nagios_hostgroup <<||>> { notify => Service['nagios'] }
Nagios_hostdependency <<||>> { notify => Service['nagios'] }
Nagios_hostescalation <<||>> { notify => Service['nagios'] }
Nagios_hostextinfo <<||>> { notify => Service['nagios'] }
Nagios_service <<||>> { notify => Service['nagios'] }
Nagios_servicegroup <<||>> { notify => Service['nagios'] }
Nagios_servicedependency <<||>> { notify => Service['nagios'] }
Nagios_serviceescalation <<||>> { notify => Service['nagios'] }
Nagios_serviceextinfo <<||>> { notify => Service['nagios'] }
Nagios_contact <<||>> { notify => Service['nagios'] }
Nagios_contactgroup <<||>> { notify => Service['nagios'] }
Nagios_command <<||>> { notify => Service['nagios'] }
Nagios_timeperiod <<||>> { notify => Service['nagios'] }
}
}