munin: Merged munin::disable into munin::plugin

This commit is contained in:
Ossi Salmi 2013-06-17 12:40:04 +03:00
parent e577489411
commit b8b853da05

View file

@ -141,6 +141,8 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
#
# $name:
# Plugin name to install.
# $enable:
# Set to false to disable plugin.
# $config:
# Configuration file name associated with plugin. Defaults to none.
#
@ -150,53 +152,20 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
# config => "vmware",
# }
#
define munin::plugin($config = "") {
define munin::plugin($enable=true, $config="") {
if $enable == true {
case $::operatingsystem {
OpenBSD: {
"openbsd": {
file { "/usr/local/libexec/munin/plugins/${name}":
ensure => present,
source => "puppet:///modules/munin/plugins/${name}",
mode => "0755",
owner => "root",
group => "wheel",
mode => "0755",
source => [ "puppet:///files/munin/plugins/${name}",
"puppet:///modules/munin/plugins/${name}", ],
require => Package["munin-node"],
}
}
default: {
file { "/usr/share/munin/plugins/${name}":
ensure => present,
source => "puppet:///modules/munin/plugins/${name}",
owner => "root",
group => "root",
mode => "0755",
require => Package["munin-node"],
}
}
}
if ($config) {
file { "/etc/munin/plugin-conf.d/${config}":
ensure => present,
source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}",
"puppet:///files/munin/plugin-conf/${config}",
"puppet:///modules/munin/plugin-conf/${config}", ],
owner => "root",
group => $::operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
mode => "0644",
notify => Service["munin-node"],
require => $::operatingsystem ? {
"openbsd" => File["/usr/local/libexec/munin/plugins/${name}"],
default => File["/usr/share/munin/plugins/${name}"],
},
}
}
case $::operatingsystem {
OpenBSD: {
exec { "munin-enable-${name}":
command => "ln -s /usr/local/libexec/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
@ -208,6 +177,15 @@ define munin::plugin($config = "") {
}
}
default: {
file { "/usr/share/munin/plugins/${name}":
ensure => present,
mode => "0755",
owner => "root",
group => "root",
source => [ "puppet:///files/munin/plugins/${name}",
"puppet:///modules/munin/plugins/${name}", ],
require => Package["munin-node"],
}
exec { "munin-enable-${name}":
command => "ln -s /usr/share/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
@ -220,13 +198,23 @@ define munin::plugin($config = "") {
}
}
}
# Disable munin plugin.
#
define munin::disable() {
if $config {
file { "/etc/munin/plugin-conf.d/${config}":
ensure => present,
mode => "0644",
owner => "root",
group => $::operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}",
"puppet:///files/munin/plugin-conf/${config}",
"puppet:///modules/munin/plugin-conf/${config}", ],
notify => Service["munin-node"],
before => Exec["munin-enable-name"],
}
}
} else {
file { "/etc/munin/plugin-conf.d/${name}":
ensure => present,
mode => "0644",
@ -238,6 +226,7 @@ define munin::disable() {
content => "[${name}]\ncommand /bin/true\n",
notify => Exec["munin-node-configure"],
}
}
}