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