munin: Make source optional for munin::plugin to allow deploying just configurations

This commit is contained in:
Ossi Salmi 2013-07-18 18:42:20 +03:00
parent 05ac584cbf
commit 21f4caa533

View file

@ -135,7 +135,7 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
} }
# Add new custom munin plugin. # Add new munin plugin or plugin configuration.
# #
# === Parameters # === Parameters
# #
@ -144,9 +144,9 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
# $enable: # $enable:
# Set to false to disable plugin. # Set to false to disable plugin.
# $source: # $source:
# Source path for the plugin. # Source path of the plugin.
# $config: # $config:
# Source path of plugin configuration file. Defaults to none. # Source path of plugin configuration file.
# #
# === Sample usage # === Sample usage
# #
@ -158,10 +158,6 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
define munin::plugin($enable=true, $source=undef, $config=undef) { define munin::plugin($enable=true, $source=undef, $config=undef) {
if $enable == true { if $enable == true {
if ! $source {
fail("Must define source parameter for Munin::Plugin[${name}]")
}
case $::operatingsystem { case $::operatingsystem {
"openbsd": { "openbsd": {
$plugindir = "/usr/local/libexec/munin/plugins" $plugindir = "/usr/local/libexec/munin/plugins"
@ -171,33 +167,34 @@ define munin::plugin($enable=true, $source=undef, $config=undef) {
} }
} }
file { "${plugindir}/${name}": if $source {
ensure => present, file { "${plugindir}/${name}":
mode => "0755", ensure => present,
owner => "root", mode => "0755",
group => $::operatingsystem ? { owner => "root",
"openbsd" => "wheel", group => $::operatingsystem ? {
default => "root", "openbsd" => "wheel",
}, default => "root",
source => $source, },
notify => Exec["munin-node-configure"], source => $source,
require => Package["munin-node"], notify => Exec["munin-node-configure"],
require => Package["munin-node"],
}
} }
file { "/etc/munin/plugin-conf.d/${name}": if $config {
ensure => $config ? { file { "/etc/munin/plugin-conf.d/${name}":
undef => absent, ensure => present,
default => present, mode => "0644",
}, owner => "root",
mode => "0644", group => $::operatingsystem ? {
owner => "root", "openbsd" => "wheel",
group => $::operatingsystem ? { default => "root",
"openbsd" => "wheel", },
default => "root", source => $config,
}, notify => Exec["munin-node-configure"],
source => $config, require => Package["munin-node"],
notify => Exec["munin-node-configure"], }
require => Package["munin-node"],
} }
} else { } else {
file { "/etc/munin/plugin-conf.d/${name}": file { "/etc/munin/plugin-conf.d/${name}":