diff options
author | mh <mh@immerda.ch> | 2015-11-28 17:41:37 +0100 |
---|---|---|
committer | mh <mh@immerda.ch> | 2015-11-28 17:41:37 +0100 |
commit | 94b40fa2975cf537dd97ac2484670bc944fa09f4 (patch) | |
tree | 7b7052ad88f26bf072315e3bdd57965227d4d959 | |
parent | c3ca4ac25d7cdfd5826149445f2946d64d968f97 (diff) |
linting for future parser
-rw-r--r-- | manifests/debian.pp | 77 | ||||
-rw-r--r-- | manifests/nrpe/base.pp | 91 | ||||
-rw-r--r-- | manifests/nrpe/command.pp | 55 | ||||
-rw-r--r-- | manifests/nsca/client.pp | 20 | ||||
-rw-r--r-- | manifests/nsca/server.pp | 16 | ||||
-rw-r--r-- | manifests/plugin/deploy.pp | 61 |
6 files changed, 171 insertions, 149 deletions
diff --git a/manifests/debian.pp b/manifests/debian.pp index 0f451e3..9b1f7e7 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -1,48 +1,49 @@ +# debian specific things class nagios::debian inherits nagios::base { - Package['nagios'] { name => 'nagios3' } + Package['nagios'] { name => 'nagios3' } - package { [ 'nagios-plugins', 'nagios-snmp-plugins','nagios-nrpe-plugin' ]: - ensure => 'present', - notify => Service['nagios'], - } + package { [ 'nagios-plugins', 'nagios-snmp-plugins','nagios-nrpe-plugin' ]: + ensure => 'present', + notify => Service['nagios'], + } - Service['nagios'] { - name => 'nagios3', - hasstatus => true, - } + Service['nagios'] { + name => 'nagios3', + hasstatus => true, + } - File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' } + File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' } - file { 'nagios_commands_cfg': - path => "${nagios::defaults::vars::int_cfgdir}/commands.cfg", - ensure => present, - notify => Service['nagios'], - mode => 0644, owner => root, group => root; - } + file{ + 'nagios_commands_cfg': + path => "${nagios::defaults::vars::int_cfgdir}/commands.cfg", + notify => Service['nagios'], + owner => root, + group => root, + mode => '0644'; + "${nagios::defaults::vars::int_cfgdir}/stylesheets": + ensure => directory, + purge => false, + recurse => true; + } - file { "${nagios::defaults::vars::int_cfgdir}/stylesheets": - ensure => directory, - purge => false, - recurse => true, + 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', + logoutput => false, + notify => Service['nagios'], } - - 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', - logoutput => false, - notify => Service['nagios'], - } - exec { 'nagios_external_cmd_perms_1': - command => 'chmod 0751 /var/lib/nagios3 && chown nagios:nagios /var/lib/nagios3', - unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3`" = "751 nagios nagios"', - notify => Service['nagios'], - } - exec { 'nagios_external_cmd_perms_2': - command => 'chmod 2751 /var/lib/nagios3/rw && chown nagios:www-data /var/lib/nagios3/rw', - unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3/rw`" = "2751 nagios www-data"', - notify => Service['nagios'], - } + exec { 'nagios_external_cmd_perms_1': + command => 'chmod 0751 /var/lib/nagios3 && chown nagios:nagios /var/lib/nagios3', + unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3`" = "751 nagios nagios"', + notify => Service['nagios'], + } + exec { 'nagios_external_cmd_perms_2': + command => 'chmod 2751 /var/lib/nagios3/rw && chown nagios:www-data /var/lib/nagios3/rw', + unless => 'test "`stat -c "%a %U %G" /var/lib/nagios3/rw`" = "2751 nagios www-data"', + notify => Service['nagios'], } + } } diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp index 17abb04..fe1cd7c 100644 --- a/manifests/nrpe/base.pp +++ b/manifests/nrpe/base.pp @@ -1,50 +1,53 @@ +# basic nrpe stuff 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 - } + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } - # 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 } + package{['nagios-nrpe-server', 'nagios-plugins-basic', 'libwww-perl']: + ensure => installed; + } - 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}", - } + # Special-case lenny. the package doesn't exist + if $::lsbdistcodename != 'lenny' { + package{'libnagios-plugin-perl': ensure => installed; } + } - service { "nagios-nrpe-server": - ensure => running, - enable => true, - pattern => "nrpe", - subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"], - require => Package["nagios-nrpe-server"], - } + 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 => '0644'; + } + + # 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 index e6ebdae..196996c 100644 --- a/manifests/nrpe/command.pp +++ b/manifests/nrpe/command.pp @@ -1,33 +1,34 @@ +# manage an nrpe command 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." ) - } + $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 - } + $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" ] - } + file{"${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg": + ensure => $ensure, + notify => Service['nagios-nrpe-server'], + require => File ["${nagios_nrpe_cfgdir}/nrpe.d" ], + owner => 'root', + group => 0, + mode => '0644'; + } - 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, - } - } + 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/nsca/client.pp b/manifests/nsca/client.pp index e58721d..6aa8c0b 100644 --- a/manifests/nsca/client.pp +++ b/manifests/nsca/client.pp @@ -1,14 +1,18 @@ +# manage nsca client class nagios::nsca::client { - package { 'nsca': ensure => installed } + 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", - "puppet:///modules/nagios/nsca/send_nsca.cfg" ], - owner => 'nagios', - group => 'nogroup', - mode => '400', + file{'/etc/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', + mode => '0400', + require => Package['nsca']; } } diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index bd5389d..8163eec 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -1,21 +1,23 @@ +# an nsca server class nagios::nsca::server { - - package { 'nsca': ensure => installed } + package{'nsca': + ensure => installed + } service { 'nsca': ensure => running, hasstatus => false, hasrestart => true, - require => Package['nsca'], + require => Package['nsca'], } file { '/etc/nsca.cfg': - source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/nsca.cfg", - "puppet:///modules/site_nagios/nsca/nsca.cfg", - "puppet:///modules/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', - mode => '400', + mode => '0400', notify => Service['nsca'], } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 3f2a1a4..7681590 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -1,30 +1,41 @@ -define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $require_package = 'nagios-plugins') { - $plugin_src = $ensure ? { - 'present' => $name, - 'absent' => $name, - default => $ensure - } - $real_source = $source ? { - '' => "nagios/plugins/${plugin_src}", - default => $source - } +# deploy a specific plugin +define nagios::plugin::deploy( + $source = '', + $ensure = 'present', + $config = '', + $require_package = 'nagios-plugins' +) { + $plugin_src = $ensure ? { + 'present' => $name, + 'absent' => $name, + default => $ensure + } + $real_source = $source ? { + '' => "nagios/plugins/${plugin_src}", + default => $source + } - if !defined(Package[$require_package]) { - package { $require_package: - ensure => installed, - tag => "nagios::plugin::deploy::package"; - } + if !defined(Package[$require_package]) { + package { $require_package: + ensure => installed, + tag => 'nagios::plugin::deploy::package'; } + } - include nagios::plugin::scriptpaths - file { "nagios_plugin_${name}": - path => "$nagios::plugin::scriptpaths::script_path/${name}", - source => "puppet:///modules/${real_source}", - mode => 0755, owner => root, group => 0, - require => Package[$require_package], - tag => "nagios::plugin::deploy::file"; - } + include ::nagios::plugin::scriptpaths + file{"nagios_plugin_${name}": + path => "${nagios::plugin::scriptpaths::script_path}/${name}", + source => "puppet:///modules/${real_source}", + require => Package[$require_package], + tag => 'nagios::plugin::deploy::file', + owner => root, + group => 0, + mode => '0755'; + } - # register the plugin - nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] } + # register the plugin + nagios::plugin{$name: + ensure => $ensure, + require => Package['nagios-plugins'] + } } |