summaryrefslogtreecommitdiff
path: root/puppet/modules/site_nagios
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2016-03-02 13:03:12 +0100
committervarac <varacanero@zeromail.org>2016-03-02 22:21:17 +0100
commitee4fc33396aa52f9ec797fd431b3027d88fa1aa7 (patch)
treedae81326cd84b9e0ff1b31c46b9e21c182d5a960 /puppet/modules/site_nagios
parent3137b588f886886e862c3da7c39ca27158a1f640 (diff)
Dont recreate nagios resources on every run
Use purging of nagios resources in a way that not all resources are recreated on every puppetrun. Resolves: #2327
Diffstat (limited to 'puppet/modules/site_nagios')
-rw-r--r--puppet/modules/site_nagios/files/configs/Debian/nagios.cfg24
-rw-r--r--puppet/modules/site_nagios/manifests/server.pp36
-rw-r--r--puppet/modules/site_nagios/manifests/server/hostgroup.pp5
-rw-r--r--puppet/modules/site_nagios/manifests/server/purge.pp19
4 files changed, 52 insertions, 32 deletions
diff --git a/puppet/modules/site_nagios/files/configs/Debian/nagios.cfg b/puppet/modules/site_nagios/files/configs/Debian/nagios.cfg
index 981dc12a..695f437b 100644
--- a/puppet/modules/site_nagios/files/configs/Debian/nagios.cfg
+++ b/puppet/modules/site_nagios/files/configs/Debian/nagios.cfg
@@ -22,18 +22,32 @@ log_file=/var/log/nagios3/nagios.log
# if you wish (as shown below), or keep them all in a single config file.
#cfg_file=/etc/nagios3/commands.cfg
-# Puppet-managed configuration files
-cfg_dir=/etc/nagios3/conf.d
+# Check_mk configuration files
+cfg_dir=/etc/nagios3/conf.d/check_mk
-# check-mk managed configuration files
-cfg_dir=/etc/nagios3/local
+# Puppet-managed configuration files
+cfg_file=/etc/nagios3/nagios_templates.cfg
+cfg_file=/etc/nagios3/nagios_command.cfg
+cfg_file=/etc/nagios3/nagios_contact.cfg
+cfg_file=/etc/nagios3/nagios_contactgroup.cfg
+cfg_file=/etc/nagios3/nagios_host.cfg
+cfg_file=/etc/nagios3/nagios_hostdependency.cfg
+cfg_file=/etc/nagios3/nagios_hostescalation.cfg
+cfg_file=/etc/nagios3/nagios_hostextinfo.cfg
+cfg_file=/etc/nagios3/nagios_hostgroup.cfg
+cfg_file=/etc/nagios3/nagios_hostgroupescalation.cfg
+cfg_file=/etc/nagios3/nagios_service.cfg
+cfg_file=/etc/nagios3/nagios_servicedependency.cfg
+cfg_file=/etc/nagios3/nagios_serviceescalation.cfg
+cfg_file=/etc/nagios3/nagios_serviceextinfo.cfg
+cfg_file=/etc/nagios3/nagios_servicegroup.cfg
+cfg_file=/etc/nagios3/nagios_timeperiod.cfg
# Debian also defaults to using the check commands defined by the debian
# nagios-plugins package
cfg_dir=/etc/nagios-plugins/config
-
# OBJECT CACHE FILE
# This option determines where object definitions are cached when
# Nagios starts/restarts. The CGIs read object definitions from
diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp
index 5c833508..bb3948c0 100644
--- a/puppet/modules/site_nagios/manifests/server.pp
+++ b/puppet/modules/site_nagios/manifests/server.pp
@@ -1,8 +1,7 @@
# configures nagios on monitoring node
+# lint:ignore:inherits_across_namespaces
class site_nagios::server inherits nagios::base {
-
- # First, purge old nagios config (see #1467)
- class { 'site_nagios::server::purge': }
+# lint:endignore
$nagios_hiera = hiera('nagios')
$nagiosadmin_pw = htpasswd_sha1($nagios_hiera['nagiosadmin_pw'])
@@ -25,10 +24,33 @@ class site_nagios::server inherits nagios::base {
stored_config => false,
}
- file { '/etc/apache2/conf.d/nagios3.conf':
- ensure => link,
- target => '/usr/share/doc/nagios3-common/examples/apache2.conf',
- notify => Service['apache']
+ # Delete nagios config files provided by packages
+ # These don't get parsed by nagios.conf, but are
+ # still irritating duplicates to the real config
+ # files deployed by puppet in /etc/nagios3/
+ file { [
+ '/etc/nagios3/conf.d/contacts_nagios2.cfg',
+ '/etc/nagios3/conf.d/extinfo_nagios2.cfg',
+ '/etc/nagios3/conf.d/generic-host_nagios2.cfg',
+ '/etc/nagios3/conf.d/generic-service_nagios2.cfg',
+ '/etc/nagios3/conf.d/hostgroups_nagios2.cfg',
+ '/etc/nagios3/conf.d/localhost_nagios2.cfg',
+ '/etc/nagios3/conf.d/pnp4nagios.cfg',
+ '/etc/nagios3/conf.d/services_nagios2.cfg',
+ '/etc/nagios3/conf.d/timeperiods_nagios2.cfg' ]:
+ ensure => absent;
+ }
+
+ # deploy apache nagios3 config
+ # until https://gitlab.com/shared-puppet-modules-group/apache/issues/11
+ # is not fixed, we need to manually deploy the config file
+ file {
+ '/etc/apache2/conf-available/nagios3.conf':
+ ensure => present,
+ source => 'puppet:///modules/nagios/configs/apache2.conf';
+ '/etc/apache2/conf-enabled/nagios3.conf':
+ ensure => link,
+ target => '/etc/apache2/conf-available/nagios3.conf';
}
include site_apache::common
diff --git a/puppet/modules/site_nagios/manifests/server/hostgroup.pp b/puppet/modules/site_nagios/manifests/server/hostgroup.pp
index 6f85ca6d..25623924 100644
--- a/puppet/modules/site_nagios/manifests/server/hostgroup.pp
+++ b/puppet/modules/site_nagios/manifests/server/hostgroup.pp
@@ -1,3 +1,6 @@
+# create a nagios hostsgroup
define site_nagios::server::hostgroup ($contact_emails) {
- nagios_hostgroup { $name: }
+ nagios_hostgroup { $name:
+ ensure => present
+ }
}
diff --git a/puppet/modules/site_nagios/manifests/server/purge.pp b/puppet/modules/site_nagios/manifests/server/purge.pp
deleted file mode 100644
index 6815a703..00000000
--- a/puppet/modules/site_nagios/manifests/server/purge.pp
+++ /dev/null
@@ -1,19 +0,0 @@
-class site_nagios::server::purge inherits nagios::base {
- # we don't want to get /etc/nagios3 and /etc/nagios3/conf.d
- # purged, cause the check-mk-config-nagios3 package
- # places its templates in /etc/nagios3/conf.d/check_mk,
- # and check_mk -O updated it's nagios config in /etc/nagios3/conf.d/check_mk
- File['nagios_cfgdir'] {
- purge => false
- }
- File['nagios_confd'] {
- purge => false
- }
-
- # only purge files in the /etc/nagios3/conf.d/ dir, not in any subdir
- exec {'purge_conf.d':
- command => '/usr/bin/find /etc/nagios3/conf.d/ -maxdepth 1 -type f -exec rm {} \;',
- onlyif => '/usr/bin/find /etc/nagios3/conf.d/ -maxdepth 1 -type f | grep -q "/etc/nagios3/conf.d"',
- require => Package['nagios']
- }
-}