diff options
author | LeLutin <gabster@lelutin.ca> | 2016-02-25 06:59:19 +0000 |
---|---|---|
committer | LeLutin <gabster@lelutin.ca> | 2016-02-25 06:59:19 +0000 |
commit | c0dee4a2393e23b226e123a427898de94b342141 (patch) | |
tree | 449a726cec957808bdc52fd8e46a6acdaead777c /manifests/nrpe | |
parent | 5163d89155eec6b6b39994d0cd18e6ceeff8b180 (diff) | |
parent | 2892e1795a823c2bee2893bc339854dd4f5e5b94 (diff) |
Merge branch 'nrpe_params' into 'master'
Nrpe params
The nagios::nrpe class is currently completely unusable with puppet 3.x+
This is because it's still relying on global variables. When one tries to setup an nrpe client with nagios::nrpe with puppet 3.x, the following error occurs:
~~~
==> jessiepuppet: Error: Failed to parse template nagios/nrpe/nrpe.cfg:
==> jessiepuppet: Filepath: /usr/lib/ruby/vendor_ruby/puppet/parser/templatewrapper.rb
==> jessiepuppet: Line: 81
==> jessiepuppet: Detail: Could not find value for 'nagios_nrpe_pid_file' at /etc/puppet/modules/nagios/templates/nrpe/nrpe.cfg:19
==> jessiepuppet: at /etc/puppet/modules/nagios/manifests/nrpe/base.pp:22 on node jessie.vagrantup.com
==> jessiepuppet: Error: Failed to parse template nagios/nrpe/nrpe.cfg:
==> jessiepuppet: Filepath: /usr/lib/ruby/vendor_ruby/puppet/parser/templatewrapper.rb
==> jessiepuppet: Line: 81
==> jessiepuppet: Detail: Could not find value for 'nagios_nrpe_pid_file' at /etc/puppet/modules/nagios/templates/nrpe/nrpe.cfg:19
==> jessiepuppet: at /etc/puppet/modules/nagios/manifests/nrpe/base.pp:22 on node jessie.vagrantup.com
~~~
This is because the values of variables defined within nagios::nrpe are not propagated into other classes anymore.
This series also changes a default behaviour for creating saner configurations by default: the dont_blame_nrpe option is changed to disable command arguments by default.
It also adds some documentation for the nagios::nrpe class since it had no explanation whatsoever of how it should be used in the README.
See merge request !18
Diffstat (limited to 'manifests/nrpe')
-rw-r--r-- | manifests/nrpe/base.pp | 17 | ||||
-rw-r--r-- | manifests/nrpe/command.pp | 10 |
2 files changed, 16 insertions, 11 deletions
diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp index 0a06144..e48e87b 100644 --- a/manifests/nrpe/base.pp +++ b/manifests/nrpe/base.pp @@ -1,7 +1,13 @@ # basic nrpe stuff class nagios::nrpe::base { - if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + # Import all variables from entry point + $cfg_dir = $::nagios::nrpe::real_cfg_dir + $pid_file = $::nagios::nrpe::real_pid_file + $plugin_dir = $::nagios::nrpe::real_plugin_dir + $server_address = $::nagios::nrpe::server_address + $allowed_hosts = $::nagios::nrpe::allowed_hosts + $dont_blame = $::nagios::nrpe::dont_blame package{['nagios-nrpe-server', 'nagios-plugins-basic', 'libwww-perl']: ensure => installed; @@ -13,12 +19,11 @@ class nagios::nrpe::base { } file{ - [ $nagios_nrpe_cfgdir, "${nagios_nrpe_cfgdir}/nrpe.d" ]: + [ $cfg_dir, "${cfg_dir}/nrpe.d" ]: ensure => directory; } - if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 } - file { "${nagios_nrpe_cfgdir}/nrpe.cfg": + file { "${cfg_dir}/nrpe.cfg": content => template('nagios/nrpe/nrpe.cfg'), owner => root, group => 0, @@ -40,14 +45,14 @@ class nagios::nrpe::base { $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}", + command_line => "${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"], + subscribe => File["${cfg_dir}/nrpe.cfg"], require => Package['nagios-nrpe-server'], } } diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp index 196996c..bdd89a7 100644 --- a/manifests/nrpe/command.pp +++ b/manifests/nrpe/command.pp @@ -8,12 +8,12 @@ define nagios::nrpe::command ( fail('Either one of $command_line or $source must be given to nagios::nrpe::command.' ) } - $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + $cfg_dir = $nagios::nrpe::real_cfg_dir - file{"${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg": + file{"${cfg_dir}/nrpe.d/${name}_command.cfg": ensure => $ensure, notify => Service['nagios-nrpe-server'], - require => File ["${nagios_nrpe_cfgdir}/nrpe.d" ], + require => File ["${cfg_dir}/nrpe.d" ], owner => 'root', group => 0, mode => '0644'; @@ -21,12 +21,12 @@ define nagios::nrpe::command ( case $source { '': { - File["${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg"] { + File["${cfg_dir}/nrpe.d/${name}_command.cfg"] { content => template('nagios/nrpe/nrpe_command.erb'), } } default: { - File["${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg"] { + File["${cfg_dir}/nrpe.d/${name}_command.cfg"] { source => $source, } } |