diff options
author | Micah Anderson <micah@riseup.net> | 2012-09-25 16:27:37 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2012-09-25 16:27:37 -0400 |
commit | 16e77b3a8b257dafcf059bfcebc095178995fda5 (patch) | |
tree | 2673fa226de03b0be14ceef4df64140372643ea6 /manifests | |
parent | ad1f714b06faf229ec1b0f310e81c425a6906581 (diff) | |
parent | eafb4c73ee82915bf83eac01bb26265c531a68e2 (diff) |
Merge branch 'merge_immerda'
Conflicts:
manifests/apache.pp
this conflict was just a indentation difference.
Diffstat (limited to 'manifests')
31 files changed, 361 insertions, 227 deletions
diff --git a/manifests/apache.pp b/manifests/apache.pp index 59a62f6..a90d0ee 100644 --- a/manifests/apache.pp +++ b/manifests/apache.pp @@ -1,21 +1,29 @@ -class nagios::apache inherits ::apache { - $nagios_httpd = 'apache' - include nagios +class nagios::apache( + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + class{'nagios': + httpd => 'apache', + allow_external_cmd => $allow_external_cmd, + manage_munin => $manage_munin, + manage_shorewall => $manage_shorewall, + } - case $operatingsystem { - 'debian': { - file { "${nagios::defaults::vars::int_nagios_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"], - } + case $::operatingsystem { + 'debian': { + file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf": + ensure => present, + source => [ "puppet:///site_nagios/configs/${::fqdn}/apache2.conf", + "puppet:///site_nagios/configs/apache2.conf", + "puppet:///nagios/configs/apache2.conf"], + } - apache::config::global { "nagios3.conf": - ensure => link, - target => "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf", - require => File["${nagios::defaults::vars::int_nagios_cfgdir}/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/base.pp b/manifests/base.pp index 589e98b..d4d6590 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -4,7 +4,7 @@ class nagios::base { package { 'nagios': alias => 'nagios', - ensure => present, + ensure => present, } service { 'nagios': @@ -16,15 +16,15 @@ class nagios::base { # this file should contain all the nagios_puppet-paths: file { 'nagios_main_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/nagios.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios.cfg", - "puppet:///modules/site-nagios/configs/nagios.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/nagios.cfg", + path => "${nagios::defaults::vars::int_cfgdir}/nagios.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg", + "puppet:///modules/site_nagios/configs/nagios.cfg", + "puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg", "puppet:///modules/nagios/configs/nagios.cfg" ], notify => Service['nagios'], mode => 0644, owner => root, group => root; - } + } file { 'nagios_commands_cfg': path => "${nagios::defaults::vars::int_nagios_cfgdir}/commands.cfg", @@ -34,26 +34,25 @@ class nagios::base { } file { 'nagios_cgi_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/cgi.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/cgi.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/cgi.cfg", - "puppet:///modules/site-nagios/configs/cgi.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/cgi.cfg", + path => "${nagios::defaults::vars::int_cfgdir}/cgi.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg", + "puppet:///modules/site_nagios/configs/cgi.cfg", + "puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg", "puppet:///modules/nagios/configs/cgi.cfg" ], mode => '0644', owner => 'root', group => 0, notify => Service['apache'], } file { 'nagios_htpasswd': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/htpasswd.users", - source => [ "puppet:///modules/site-nagios/htpasswd.users", + path => "${nagios::defaults::vars::int_cfgdir}/htpasswd.users", + source => [ "puppet:///modules/site_nagios/htpasswd.users", "puppet:///modules/nagios/htpasswd.users" ], mode => 0640, owner => root, group => apache; } file { 'nagios_private': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/private/", ensure => directory, purge => true, recurse => true, @@ -62,24 +61,21 @@ class nagios::base { } file { 'nagios_private_resource_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg", - source => [ "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", - "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ], + path => "${nagios::defaults::vars::int_cfgdir}/private/resource.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}", + "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ], notify => Service['nagios'], owner => root, group => nagios, mode => '0640'; } file { 'nagios_confd': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/conf.d/", ensure => directory, purge => true, recurse => true, notify => Service['nagios'], mode => '0750', owner => root, group => nagios; } - Package <<| tag == 'nagios::plugin::deploy::package' |>> - File <<| tag == 'nagios::plugin::deploy::file' |>> Nagios_command <<||>> Nagios_contactgroup <<||>> Nagios_contact <<||>> @@ -94,91 +90,90 @@ class nagios::base { Nagios_serviceextinfo <<||>> Nagios_service <<||>> Nagios_timeperiod <<||>> - File <<| tag == 'nagios_plugin' |>> Nagios_command <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contact <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contactgroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_host <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostdependency <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", notify => Service['nagios'], } Nagios_hostescalation <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", notify => Service['nagios'], } Nagios_hostextinfo <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostgroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_service <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_servicegroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg", notify => Service['nagios'], } Nagios_servicedependency <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceescalation <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceextinfo <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_timeperiod <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg", require => File['nagios_confd'], notify => Service['nagios'], } - file{[ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: + file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: ensure => file, replace => false, notify => Service['nagios'], @@ -188,17 +183,11 @@ class nagios::base { # manage nagios cfg files # must be defined after exported resource overrides and cfg file defs file { 'nagios_cfgdir': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/", ensure => directory, recurse => true, purge => true, notify => Service['nagios'], mode => 0755, owner => root, group => root; } - - if $use_munin { - include nagios::munin - } - } diff --git a/manifests/centos.pp b/manifests/centos.pp index 35379b8..5a2ba23 100644 --- a/manifests/centos.pp +++ b/manifests/centos.pp @@ -9,7 +9,7 @@ class nagios::centos inherits nagios::base { hasstatus => true, } - if ($nagios_allow_external_cmd) { + if $nagios::allow_external_cmd { file { '/var/spool/nagios/cmd': ensure => 'directory', require => Package['nagios'], diff --git a/manifests/debian.pp b/manifests/debian.pp index b9e87ec..bb9bb38 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -14,13 +14,13 @@ class nagios::debian inherits nagios::base { File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' } - file { "${nagios::defaults::vars::int_nagios_cfgdir}/stylesheets": + file { "${nagios::defaults::vars::int_cfgdir}/stylesheets": ensure => directory, purge => false, recurse => true, } - if ($nagios_allow_external_cmd) { + if $nagios::allow_external_cmd { exec { 'nagios_external_cmd_perms_overrides': command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3', unless => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3', diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index 1213485..bb19638 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -4,7 +4,7 @@ class nagios::defaults::commands { include nagios::command::imap_pop3 # common service commands - case $operatingsystem { + case $::operatingsystem { debian,ubuntu: { nagios_command { check_dummy: @@ -66,7 +66,7 @@ class nagios::defaults::commands { check_http_url: command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$'; check_http_url_regex: - command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$'; + command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$'; check_https_url: command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; check_https_url_regex: @@ -124,7 +124,7 @@ class nagios::defaults::commands { # notification commands - $mail_cmd_location = $operatingsystem ? { + $mail_cmd_location = $::operatingsystem ? { centos => '/bin/mail', default => '/usr/bin/mail' } diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp index 18f8161..abd8b52 100644 --- a/manifests/defaults/plugins.pp +++ b/manifests/defaults/plugins.pp @@ -1,5 +1,4 @@ class nagios::defaults::plugins { - nagios::plugin { 'check_mysql_health': source => 'nagios/plugins/check_mysql_health'; @@ -8,5 +7,4 @@ class nagios::defaults::plugins { 'check_dnsbl': source => 'nagios/plugins/check_dnsbl'; } - } diff --git a/manifests/defaults/templates.pp b/manifests/defaults/templates.pp index c97eee4..0e73c97 100644 --- a/manifests/defaults/templates.pp +++ b/manifests/defaults/templates.pp @@ -1,15 +1,15 @@ class nagios::defaults::templates { - include nagios::defaults::vars + include nagios::defaults::vars - file { 'nagios_templates': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_templates.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios_templates.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet:///modules/site-nagios/configs/nagios_templates.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet:///modules/nagios/configs/nagios_templates.cfg" ], - notify => Service['nagios'], - mode => 0644, owner => root, group => root; - } + file { 'nagios_templates': + path => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_templates.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios_templates.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios_templates.cfg", + "puppet:///modules/site_nagios/configs/nagios_templates.cfg", + "puppet:///modules/nagios/configs/${::operatingsystem}/nagios_templates.cfg", + "puppet:///modules/nagios/configs/nagios_templates.cfg" ], + notify => Service['nagios'], + mode => 0644, owner => root, group => root; + } } diff --git a/manifests/defaults/vars.pp b/manifests/defaults/vars.pp index 6302f13..87f41f8 100644 --- a/manifests/defaults/vars.pp +++ b/manifests/defaults/vars.pp @@ -1,10 +1,10 @@ class nagios::defaults::vars { - case $nagios_cfgdir { - '': { $int_nagios_cfgdir = $operatingsystem ? { + case $nagios::cfgdir { + '': { $int_cfgdir = $::operatingsystem ? { centos => '/etc/nagios/', default => '/etc/nagios3' } } - default: { $int_nagios_cfgdir = $nagios_cfgdir } + default: { $int_cfgdir = $nagios::cfgdir } } } diff --git a/manifests/init.pp b/manifests/init.pp index 1aecc3a..12d3db2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -8,28 +8,36 @@ # Marcel Härry haerry+puppet(at)puzzle.ch # Simon Josi josi+puppet(at)puzzle.ch # -# This program is free software; you can redistribute -# it and/or modify it under the terms of the GNU -# General Public License version 3 as published by +# This program is free software; you can redistribute +# it and/or modify it under the terms of the GNU +# General Public License version 3 as published by # the Free Software Foundation. # -class nagios { - case $nagios_httpd { - 'absent': { } - 'lighttpd': { include lighttpd } - 'apache': { include apache } - default: { include apache } +class nagios( + $httpd = 'apache', + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + case $nagios::httpd { + 'absent': { } + 'lighttpd': { include ::lighttpd } + 'apache': { include ::apache } + default: { include ::apache } + } + case $::operatingsystem { + 'centos': { + $cfgdir = '/etc/nagios' + include nagios::centos } - case $operatingsystem { - 'centos': { - $nagios_cfgdir = '/etc/nagios' - include nagios::centos - } - 'debian': { - $nagios_cfgdir = '/etc/nagios3' - include nagios::debian - } - default: { fail("No such operatingsystem: $operatingsystem yet defined") } + 'debian': { + $cfgdir = '/etc/nagios3' + include nagios::debian } + default: { fail("No such operatingsystem: ${::operatingsystem} yet defined") } + } + if $manage_munin { + include nagios::munin + } } diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 7629b94..a034fe0 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,22 +1,22 @@ class nagios::irc_bot { - if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) { - fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel") + if ( ! ($nsa_server and $nsa_nickname and $nsa_channel) ) { + fail("Please provide values at least for \$nsa_server, \$nsa_nickname and \$nsa_channel") } case $operatingsystem { centos: { - $nagios_nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' - $nagios_nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' + $nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' include nagios::irc_bot::centos } default: { - $nagios_nsa_default_socket = '/var/run/nagios3/nsa.socket' - $nagios_nsa_default_pidfile = '/var/run/nagios3/nsa.pid' + $nsa_default_socket = '/var/run/nagios3/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios3/nsa.pid' include nagios::irc_bot::base } } - if $use_shorewall { + if $nagios::manage_shorewall { include shorewall::rules::out::irc } } diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp index c36d8e6..6fab2ac 100644 --- a/manifests/irc_bot/base.pp +++ b/manifests/irc_bot/base.pp @@ -1,29 +1,29 @@ class nagios::irc_bot::base { # Default values for the two first variables are defined in nagios::irc_bot - $nagios_nsa_socket = $nagios_nsa_socket ? { - '' => $nagios_nsa_default_socket, - default => $nagios_nsa_socket, + $nsa_socket = $nsa_socket ? { + '' => $nsa_default_socket, + default => $nsa_socket, } - $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { - '' => $nagios_nsa_default_pidfile, - default => $nagios_nsa_pidfile, + $nsa_pidfile = $nsa_pidfile ? { + '' => $nsa_default_pidfile, + default => $nsa_pidfile, } - $nagios_nsa_port = $nagios_nsa_port ? { + $nsa_port = $nsa_port ? { '' => '6667', - default => $nagios_nsa_port, + default => $nsa_port, } - $nagios_nsa_realname = $nagios_nsa_realname ? { + $nsa_realname = $nsa_realname ? { '' => 'Nagios', - default => $nagios_nsa_realname, + default => $nsa_realname, } - if (! $nagios_nsa_password) { - $nagios_nsa_password = '' + if (! $nsa_password) { + $nsa_password = '' } - if (! $nagios_nsa_usenotices) { - $nagios_nsa_usenotices = '' + if (! $nsa_usenotices) { + $nsa_usenotices = '' } file { "/usr/local/bin/riseup-nagios-client.pl": diff --git a/manifests/lighttpd.pp b/manifests/lighttpd.pp index 27aff43..0f29896 100644 --- a/manifests/lighttpd.pp +++ b/manifests/lighttpd.pp @@ -1,4 +1,12 @@ -class nagios::lighttpd { - $nagios_httpd = 'lighttpd' - include nagios +class nagios::lighttpd( + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + class{'nagios': + httpd => 'lighttpd', + allow_external_cmd => $allow_external_cmd, + manage_munin => $manage_munin, + manage_shorewall => $manage_shorewall, + } } diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp index ff22441..5c05ed4 100644 --- a/manifests/nrpe.pp +++ b/manifests/nrpe.pp @@ -1,37 +1,22 @@ class nagios::nrpe { - if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + case $operatingsystem { + 'FreeBSD': { + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' } + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' } - package { "nagios-nrpe-server": ensure => latest; - "nagios-plugins-basic": ensure => latest; - "nagios-plugins-standard": ensure => latest; - "libnagios-plugin-perl": ensure => present; - "libwww-perl": ensure => present; # für check_apache - "ksh": ensure => present; # für check_cpustats.sh - "sysstat": ensure => present; # für check_cpustats.sh - } + include nagios::nrpe::freebsd + } + default: { + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' } - file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]: - ensure => directory } - - file { "$nagios_nrpe_cfgdir/nrpe.cfg": - content => template('nagios/nrpe/nrpe.cfg'), - owner => root, group => root, mode => 644; - } - - # default commands - file { "$nagios_nrpe_cfgdir/nrpe.d/nrpe_commands.cfg": - source => [ "puppet:///site-nagios/nrpe/nrpe_commands.cfg", - "puppet:///nagios/nrpe/nrpe_commands.cfg" ], - owner => root, group => root, mode => 644; - } - - service { "nagios-nrpe-server": - ensure => running, - enable => true, - pattern => "nrpe", - subscribe => [ File["$nagios_nrpe_cfgdir/nrpe.cfg"], - File["$nagios_nrpe_cfgdir/nrpe.d/nrpe_commands.cfg"] ] - } + case $kernel { + linux: { include nagios::nrpe::linux } + default: { include nagios::nrpe::base } + } + } + } } diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp new file mode 100644 index 0000000..17abb04 --- /dev/null +++ b/manifests/nrpe/base.pp @@ -0,0 +1,50 @@ +class nagios::nrpe::base { + + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + if $processorcount == '' { $processorcount = 1 } + + package { "nagios-nrpe-server": ensure => present; + "nagios-plugins-basic": ensure => present; + "libwww-perl": ensure => present; # for check_apache + } + + # Special-case lenny. the package doesn't exist + if $lsbdistcodename != 'lenny' { + package { "libnagios-plugin-perl": ensure => present; } + } + + file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]: + ensure => directory } + + if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 } + file { "$nagios_nrpe_cfgdir/nrpe.cfg": + content => template('nagios/nrpe/nrpe.cfg'), + owner => root, group => 0, mode => 644; + } + + # default commands + nagios::nrpe::command { "basic_nrpe": + source => [ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.${fqdn}.cfg", + "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.cfg", + "puppet:///modules/nagios/nrpe/nrpe_commands.cfg" ], + } + # the check for load should be customized for each server based on number + # of CPUs and the type of activity. + $warning_1_threshold = 7 * $processorcount + $warning_5_threshold = 6 * $processorcount + $warning_15_threshold = 5 * $processorcount + $critical_1_threshold = 10 * $processorcount + $critical_5_threshold = 9 * $processorcount + $critical_15_threshold = 8 * $processorcount + nagios::nrpe::command { "check_load": + command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}", + } + + service { "nagios-nrpe-server": + ensure => running, + enable => true, + pattern => "nrpe", + subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"], + require => Package["nagios-nrpe-server"], + } +} diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp new file mode 100644 index 0000000..e6ebdae --- /dev/null +++ b/manifests/nrpe/command.pp @@ -0,0 +1,33 @@ +define nagios::nrpe::command ( + $ensure = present, + $command_line = '', + $source = '' ) +{ + if ($command_line == '' and $source == '') { + fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." ) + } + + if $nagios_nrpe_cfg_dir == '' { + $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + } + + file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg": + ensure => $ensure, + mode => 644, owner => root, group => 0, + notify => Service['nagios-nrpe-server'], + require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] + } + + case $source { + '': { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + content => template( "nagios/nrpe/nrpe_command.erb" ), + } + } + default: { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + source => $source, + } + } + } +} diff --git a/manifests/nrpe/freebsd.pp b/manifests/nrpe/freebsd.pp new file mode 100644 index 0000000..063b79b --- /dev/null +++ b/manifests/nrpe/freebsd.pp @@ -0,0 +1,16 @@ +class nagios::nrpe::freebsd inherits nagios::nrpe::base { + + Package["nagios-nrpe-server"] { name => "nrpe" } + Package["nagios-plugins-basic"] { name => "nagios-plugins" } + Package["libnagios-plugin-perl"] { name => "p5-Nagios-Plugin" } + Package["libwww-perl"] { name => "p5-libwww" } + + # TODO check_cpustats.sh is probably not working as of now. the package 'sysstat' is not available under FreeBSD + + Service["nagios-nrpe-server"] { + pattern => "^/usr/local/sbin/nrpe2", + path => "/usr/local/etc/rc.d", + name => "nrpe2", + hasstatus => "false", + } +} diff --git a/manifests/nrpe/linux.pp b/manifests/nrpe/linux.pp new file mode 100644 index 0000000..14e007f --- /dev/null +++ b/manifests/nrpe/linux.pp @@ -0,0 +1,9 @@ +class nagios::nrpe::linux inherits nagios::nrpe::base { + + package { + "nagios-plugins-standard": ensure => present; + "ksh": ensure => present; # for check_cpustats.sh + "sysstat": ensure => present; # for check_cpustats.sh + } + +} diff --git a/manifests/nrpe/xinetd.pp b/manifests/nrpe/xinetd.pp new file mode 100644 index 0000000..e13ed76 --- /dev/null +++ b/manifests/nrpe/xinetd.pp @@ -0,0 +1,11 @@ +# This is created only to cope with cases where we're not the only ones +# administering a machine and NRPE is running in xinetd. +class nagios::nrpe::xinetd inherits base { + + Service ["nagios-nrpe-server"] { + ensure => stopped, + } + + # TODO manage the xinetd config file that glues with NRPE + +} diff --git a/manifests/nsca/client.pp b/manifests/nsca/client.pp index 6e2c472..e58721d 100644 --- a/manifests/nsca/client.pp +++ b/manifests/nsca/client.pp @@ -1,10 +1,10 @@ class nagios::nsca::client { package { 'nsca': ensure => installed } - + file { '/etc/send_nsca.cfg': - source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/send_nsca.cfg", - "puppet:///modules/site-nagios/nsca/send_nsca.cfg", + source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/send_nsca.cfg", + "puppet:///modules/site_nagios/nsca/send_nsca.cfg", "puppet:///modules/nagios/nsca/send_nsca.cfg" ], owner => 'nagios', group => 'nogroup', diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index 238e49e..bd5389d 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -10,8 +10,8 @@ class nagios::nsca::server { } file { '/etc/nsca.cfg': - source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/nsca.cfg", - "puppet:///modules/site-nagios/nsca/nsca.cfg", + source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/nsca.cfg", + "puppet:///modules/site_nagios/nsca/nsca.cfg", "puppet:///modules/nagios/nsca/nsca.cfg" ], owner => 'nagios', group => 'nogroup', diff --git a/manifests/plugin.pp b/manifests/plugin.pp index abaa6e5..d32606b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -2,15 +2,15 @@ define nagios::plugin( $source = 'absent', $ensure = present ){ - @@file{$name: - path => $hardwaremodel ? { - 'x86_64' => "/usr/lib64/nagios/plugins/$name", - default => "/usr/lib/nagios/plugins/$name", + file{$name: + path => $::hardwaremodel ? { + 'x86_64' => "/usr/lib64/nagios/plugins/${name}", + default => "/usr/lib/nagios/plugins/${name}", }, ensure => $ensure, source => $source ? { - 'absent' => "puppet:///modules/nagios/plugins/$name", - default => "puppet:///modules/$source" + 'absent' => "puppet:///modules/nagios/plugins/${name}", + default => "puppet:///modules/${source}" }, tag => 'nagios_plugin', require => Package['nagios-plugins'], diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 75f87d7..3f2a1a4 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -5,26 +5,26 @@ define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $ default => $ensure } $real_source = $source ? { - '' => "nagios/plugins/$plugin_src", + '' => "nagios/plugins/${plugin_src}", default => $source } if !defined(Package[$require_package]) { - @@package { $require_package: + package { $require_package: ensure => installed, tag => "nagios::plugin::deploy::package"; } } - + include nagios::plugin::scriptpaths - @@file { "nagios_plugin_${name}": + file { "nagios_plugin_${name}": path => "$nagios::plugin::scriptpaths::script_path/${name}", - source => "puppet://$server/modules/$real_source", + source => "puppet:///modules/${real_source}", mode => 0755, owner => root, group => 0, require => Package[$require_package], tag => "nagios::plugin::deploy::file"; } # register the plugin - @@nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] } + nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] } } diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp index 6065709..9cd4b5d 100644 --- a/manifests/plugin/scriptpaths.pp +++ b/manifests/plugin/scriptpaths.pp @@ -1,5 +1,5 @@ class nagios::plugin::scriptpaths { - case $hardwaremodel { + case $::hardwaremodel { x86_64: { $script_path = "/usr/lib64/nagios/plugins/" } default: { $script_path = "/usr/lib/nagios/plugins" } } diff --git a/manifests/plugins/jabber.pp b/manifests/plugins/jabber.pp new file mode 100644 index 0000000..380a5c0 --- /dev/null +++ b/manifests/plugins/jabber.pp @@ -0,0 +1,10 @@ +class nagios::plugins::jabber { + + # for check_jabber_login + require rubygems::xmpp4r + + nagios::plugin { 'check_jabber_login': + source => 'nagios/plugins/check_jabber_login' + } +} + diff --git a/manifests/service.pp b/manifests/service.pp index 55b2254..71f78b0 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,6 @@ define nagios::service ( $ensure = present, - $host_name = $fqdn, + $host_name = $::fqdn, $check_command, $check_period = '', $normal_check_interval = '', @@ -19,7 +19,7 @@ define nagios::service ( # TODO: this resource should normally accept all nagios_host parameters - $real_name = "${hostname}_${name}" + $real_name = "${::hostname}_${name}" if ($use_nrpe == 'true') { include nagios::command::nrpe_timeout diff --git a/manifests/service/http.pp b/manifests/service/http.pp index 8fd5059..ef63abb 100644 --- a/manifests/service/http.pp +++ b/manifests/service/http.pp @@ -6,6 +6,7 @@ define nagios::service::http( $ensure = present, $check_domain = 'absent', + $port = '80', $check_url = '/', $check_code = 'OK', $use = 'generic-service', @@ -27,7 +28,7 @@ define nagios::service::http( nagios::service{"httprd_${name}": ensure => $ensure, use => $use, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'", + check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'301'", } } } @@ -38,7 +39,7 @@ define nagios::service::http( nagios::service{"http_${name}_${check_code}": ensure => $ensure, use => $use, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'", + check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'${check_code}'", } } } diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp index 2fde402..94881d8 100644 --- a/manifests/service/mysql.pp +++ b/manifests/service/mysql.pp @@ -1,11 +1,11 @@ -# Checks a mysql instance via tcp or socket +# Checks a mysql instance via tcp or socket define nagios::service::mysql( $ensure = present, $check_host = 'absent', $check_port = '3306', $check_username = 'nagios', - $check_password = $nagios_mysql_password, + $check_password = trocla("mysql_nagios_${::fqdn}",'plain','length: 32'), $check_database = 'information_schema', $check_warning = undef, $check_critical = undef, @@ -28,7 +28,7 @@ define nagios::service::mysql( if $check_warning != undef { $real_check_warning = "!--warning $check_warning" } - + if $check_critical != undef { $real_check_critical = "!--critical $check_critical" } @@ -51,7 +51,7 @@ define nagios::service::mysql( } } } - + nagios::service { "mysql_health_${name}": ensure => $ensure, check_command => "check_mysql_health!${real_check_host}!${check_port}!${check_username}!${check_password}!${check_health_mode}!${check_database}${real_check_name}${real_check_warning}${real_check_critical}", diff --git a/manifests/service/ntp.pp b/manifests/service/ntp.pp index eca255a..b3cde2a 100644 --- a/manifests/service/ntp.pp +++ b/manifests/service/ntp.pp @@ -1,9 +1,9 @@ # manifests/service/ntp.pp class nagios::service::ntp { - nagios::service{ "check_ntp": - check_command => "check_ntp_time", - host_name => $fqdn, - } + nagios::service{ "check_ntp": + check_command => "check_ntp_time", + host_name => $::fqdn, + } } diff --git a/manifests/service/ping.pp b/manifests/service/ping.pp index c705c68..f1c8d87 100644 --- a/manifests/service/ping.pp +++ b/manifests/service/ping.pp @@ -1,13 +1,9 @@ define nagios::service::ping( - $ensure = present + $ensure = present, + $ping_rate = '!100.0,20%!500.0,60%' ){ - $real_nagios_ping_rate = $nagios_ping_rate ? { - '' => '!100.0,20%!500.0,60%', - default => $nagios_ping_rate - } - - nagios::service{ "check_ping": - ensure => $ensure, - check_command => "check_ping${real_nagios_ping_rate}", - } + nagios::service{ "check_ping": + ensure => $ensure, + check_command => "check_ping${ping_rate}", + } } diff --git a/manifests/target.pp b/manifests/target.pp index 675ac1a..f9b7e13 100644 --- a/manifests/target.pp +++ b/manifests/target.pp @@ -1,15 +1,22 @@ # manifests/target.pp -class nagios::target { +class nagios::target( + $parents = 'absent', + $address = $::ipaddress, + $nagios_alias = $::hostname, + $hostgroups = 'absent' +){ + @@nagios_host { $::fqdn: + address => $address, + alias => $nagios_alias, + use => 'generic-host', + } - @@nagios_host { "${fqdn}": - address => $ipaddress, - alias => $hostname, - use => 'generic-host', - } - - if ($nagios_parents != '') { - Nagios_host["${fqdn}"] { parents => $nagios_parents } - } + if ($parents != 'absent') { + Nagios_host["${::fqdn}"] { parents => $parents } + } + if ($hostgroups != 'absent') { + Nagios_host["${::fqdn}"] { hostgroups => $hostgroups } + } } diff --git a/manifests/target/fqdn.pp b/manifests/target/fqdn.pp index acac5d6..6bb16c1 100644 --- a/manifests/target/fqdn.pp +++ b/manifests/target/fqdn.pp @@ -1,5 +1,10 @@ -class nagios::target::fqdn inherits nagios::target { - - Nagios_host["${fqdn}"] { address => "${fqdn}" } - +class nagios::target::fqdn( + $hostgroups = 'absent', + $parents = 'absent' +) { + class{'nagios::target': + address => $::fqdn, + hostgroups => $hostgroups, + parents => $parents + } } |