Skip to content

Commit

Permalink
Clean up nagios::nrpe_service and use stdlib's join()
Browse files Browse the repository at this point in the history
  • Loading branch information
thias committed Jul 29, 2014
1 parent 8fe0014 commit 4d89fb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ license 'Apache 2.0'
summary 'Nagios client and server module'
description "Install and configure one or more nagios servers to monitor all of your puppet-managed nodes."
project_page 'https://github.com/thias/puppet-nagios'
dependency 'puppetlabs/stdlib', '>= 2.0.0'
22 changes: 12 additions & 10 deletions manifests/nrpe_service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@
# }
#
define nagios::nrpe_service (
$ensure = present,
$plugin,
$args = undef,
$sudo = false,
$sudo_user = undef,
$ensure = present,
$args = undef,
$sudo = false,
$sudo_user = undef,
$depends_on_nrpe = undef,
$use_extra = [],
$use_extra = [],
) {

if (' ' in $name) {
fail("name ${name} cannot contain spaces")
}

$host_name = $nagios::client::host_name
$host_name = $::nagios::client::host_name

# FIXME: without nagios::client, applying a manifest with only an
# nrpe_service fails because it doesn't find Service['nrpe']
include nagios::client
include nagios::params
include '::nagios::client'
include '::nagios::params'

# client-side definition of nrpe command
# goes in /etc/nagios/nrpe.d/nrpe-$name.cfg
Expand All @@ -66,14 +66,15 @@
nagios_command { "check_nrpe_${name}":
ensure => $ensure,
# -u turns socket timeout into unknowns
command_line => "${nagios::params::nrpe} -u -c check_${name}"
command_line => "${::nagios::params::nrpe} -u -c check_${name}"
}

# server-side definition of nagios service to check
# we use the nagios client host_name because the service name needs to
# be unique over all clients on the server
if ($use_extra) {
$use = inline_template('<%= (["nrpe-service"] + @use_extra).join(",") %>')
$use_extra_string = join($user_extra,',')
$use = "nrpe-service,${use_extra_string}"
} else {
$use = 'nrpe-service'
}
Expand All @@ -98,3 +99,4 @@
}

}

0 comments on commit 4d89fb5

Please sign in to comment.