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: # $name:
# Plugin name to install. # Plugin name to install.
# $enable:
# Set to false to disable plugin.
# $config: # $config:
# Configuration file name associated with plugin. Defaults to none. # Configuration file name associated with plugin. Defaults to none.
# #
@ -150,95 +152,82 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
# config => "vmware", # config => "vmware",
# } # }
# #
define munin::plugin($config = "") { define munin::plugin($enable=true, $config="") {
case $::operatingsystem { if $enable == true {
OpenBSD: { case $::operatingsystem {
file { "/usr/local/libexec/munin/plugins/${name}": "openbsd": {
ensure => present, file { "/usr/local/libexec/munin/plugins/${name}":
source => "puppet:///modules/munin/plugins/${name}", ensure => present,
owner => "root", mode => "0755",
group => "wheel", owner => "root",
mode => "0755", group => "wheel",
require => Package["munin-node"], source => [ "puppet:///files/munin/plugins/${name}",
"puppet:///modules/munin/plugins/${name}", ],
require => Package["munin-node"],
}
exec { "munin-enable-${name}":
command => "ln -s /usr/local/libexec/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/local/libexec/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/local/libexec/munin/plugins/${name}"],
}
}
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",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/share/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/share/munin/plugins/${name}"],
}
} }
} }
default: {
file { "/usr/share/munin/plugins/${name}": if $config {
file { "/etc/munin/plugin-conf.d/${config}":
ensure => present, ensure => present,
source => "puppet:///modules/munin/plugins/${name}", mode => "0644",
owner => "root", owner => "root",
group => "root", group => $::operatingsystem ? {
mode => "0755", "openbsd" => "wheel",
require => Package["munin-node"], 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}":
if ($config) {
file { "/etc/munin/plugin-conf.d/${config}":
ensure => present, ensure => present,
source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}", mode => "0644",
"puppet:///files/munin/plugin-conf/${config}",
"puppet:///modules/munin/plugin-conf/${config}", ],
owner => "root", owner => "root",
group => $::operatingsystem ? { group => $::operatingsystem ? {
"openbsd" => "wheel", "openbsd" => "wheel",
default => "root", default => "root",
}, },
mode => "0644", content => "[${name}]\ncommand /bin/true\n",
notify => Service["munin-node"], notify => Exec["munin-node-configure"],
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",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/local/libexec/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/local/libexec/munin/plugins/${name}"],
}
}
default: {
exec { "munin-enable-${name}":
command => "ln -s /usr/share/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/share/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/share/munin/plugins/${name}"],
}
}
}
}
# Disable munin plugin.
#
define munin::disable() {
file { "/etc/munin/plugin-conf.d/${name}":
ensure => present,
mode => "0644",
owner => "root",
group => $::operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
content => "[${name}]\ncommand /bin/true\n",
notify => Exec["munin-node-configure"],
}
} }