summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Filion <gabster@lelutin.ca>2015-10-02 18:26:45 -0400
committerGabriel Filion <gabster@lelutin.ca>2015-10-02 19:12:05 -0400
commit2ee46c9a31a56110a38d5a076af84448643bd85b (patch)
treed8d0ade5839c6caf3bc9c7166829fde9aa2d52ea
parent63b80c9c238b19635665cfe20c2c8bd79994ab15 (diff)
files managed for apache on debian break usage through main class
Currently the nagios::apache class manages some files for debian. This means that when using the main class for setting up nagios with apache (which is the default!) lacks those files and the setup doesn't work. Split out management of those files into another class to avoid making the code in the main class too encumbered and make the main class include that (instead of nagios::apache). nagios::apache will include the main class anyway. Adjust README file so that all cases of http management are done through the "nagios" class.
-rw-r--r--README8
-rw-r--r--manifests/apache.pp23
-rw-r--r--manifests/debian/apache.pp23
-rw-r--r--manifests/init.pp7
4 files changed, 36 insertions, 25 deletions
diff --git a/README b/README
index 8a47ddd..2b3791d 100644
--- a/README
+++ b/README
@@ -22,9 +22,9 @@ Monitor
-------
On one node the "nagios" class has to be included. By default this installs
-apache using the "apache" module. To use lighttpd instead, include
-"nagios::lighttpd", or, if the web server is not to be managed by puppet,
-include "nagios::headless".
+apache using the "apache" module. To use lighttpd instead, set the "httpd"
+parameter to the "nagios" class to "lighttpd", or, if the web server is not to
+be managed by puppet, set the "httpd" parameter to "absent".
Hosts
@@ -206,7 +206,7 @@ Usage example:
~~~
node nagios {
- class { 'nagios::apache': } -> class { 'nagios::defaults': }
+ class { 'nagios': } -> class { 'nagios::defaults': }
# Declare another nagios command
nagios::command { http_port:
diff --git a/manifests/apache.pp b/manifests/apache.pp
index b89ff5d..1e4224e 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -4,26 +4,9 @@ class nagios::apache(
$manage_munin = false
) {
class{'nagios':
- httpd => 'apache',
+ httpd => 'apache',
allow_external_cmd => $allow_external_cmd,
- manage_munin => $manage_munin,
- manage_shorewall => $manage_shorewall,
- }
-
- case $::operatingsystem {
- 'debian': {
- file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
- ensure => present,
- source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/apache2.conf",
- "puppet:///modules/site_nagios/configs/apache2.conf",
- "puppet:///modules/nagios/configs/apache2.conf"],
- }
-
- apache::config::global { "nagios3.conf":
- ensure => link,
- target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
- require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
- }
- }
+ manage_munin => $manage_munin,
+ manage_shorewall => $manage_shorewall,
}
}
diff --git a/manifests/debian/apache.pp b/manifests/debian/apache.pp
new file mode 100644
index 0000000..095091e
--- /dev/null
+++ b/manifests/debian/apache.pp
@@ -0,0 +1,23 @@
+# Handle files that are specifically needed for nagios with apache on debian
+#
+# Do not include this class directly. It is included by the nagios class and
+# needs variables from it.
+#
+class nagios::debian::apache {
+
+ include nagios::defaults::vars
+
+ file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
+ ensure => present,
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/apache2.conf",
+ 'puppet:///modules/site_nagios/configs/apache2.conf',
+ 'puppet:///modules/nagios/configs/apache2.conf'],
+ }
+
+ apache::config::global { 'nagios3.conf':
+ ensure => link,
+ target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
+ }
+
+}
diff --git a/manifests/init.pp b/manifests/init.pp
index c62c480..4c68961 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -24,7 +24,12 @@ class nagios(
case $nagios::httpd {
'absent': { }
'lighttpd': { include ::lighttpd }
- 'apache': { include ::apache }
+ 'apache': {
+ include ::apache
+ if $::operatingsystem == 'debian' {
+ include nagios::debian::apache
+ }
+ }
default: { include ::apache }
}
case $::operatingsystem {