summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorMarcel Haerry <haerry@puzzle.ch>2008-04-22 11:35:05 +0200
committerMarcel Haerry <haerry@puzzle.ch>2008-04-22 11:35:05 +0200
commitb7d5281fa67ff330c28571c9b8df602acba65437 (patch)
tree14ce9205a9f50b055a43b78146bb2fbcc7e8de23 /manifests
parentebdcae0d53a7ee50e2abb2f6606f731cb76c83e8 (diff)
parentff89c05910e5185a3c5cf47bd6f4e3f52596cf33 (diff)
merged davids
Diffstat (limited to 'manifests')
-rw-r--r--manifests/client.pp124
-rw-r--r--manifests/host.pp39
-rw-r--r--manifests/init.pp22
-rw-r--r--manifests/plugin.pp128
4 files changed, 306 insertions, 7 deletions
diff --git a/manifests/client.pp b/manifests/client.pp
new file mode 100644
index 0000000..0ad7856
--- /dev/null
+++ b/manifests/client.pp
@@ -0,0 +1,124 @@
+# client.pp - configure a munin node
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+class munin::client {
+
+ $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
+ $munin_host_real = $munin_host ? {
+ '' => '*',
+ 'fqdn' => '*',
+ default => $munin_host
+ }
+
+ case $operatingsystem {
+ darwin: { include munin::client::darwin }
+ debian: {
+ include munin::client::debian
+ include munin::plugins::debian
+ }
+ ubuntu: {
+ info ( "Trying to configure Ubuntu's munin with Debian class" )
+ include munin::client::debian
+ include munin::plugins::debian
+ }
+ default: { fail ("Don't know how to handle munin on $operatingsystem") }
+ }
+
+ case $kernel {
+ linux: {
+ case $vserver {
+ guest: { include munin::plugins::vserver }
+ default: {
+ include munin::plugins::linux
+ case $virtual {
+ xen0: { include munin::plugins::xen }
+ }
+ }
+ }
+ }
+ default: {
+ err( "Don't know which munin plugins to install for $kernel" )
+ }
+ }
+
+}
+
+define munin::register()
+{
+ $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
+ $munin_host_real = $munin_host ? {
+ '' => $fqdn,
+ 'fqdn' => $fqdn,
+ default => $munin_host
+ }
+
+ @@file { "${NODESDIR}/${name}_${munin_port_real}":
+ ensure => present,
+ content => template("munin/defaultclient.erb"),
+ tag => 'munin',
+ }
+}
+
+define munin::register_snmp()
+{
+ @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
+ ensure => present,
+ content => template("munin/snmpclient.erb"),
+ tag => 'munin',
+ }
+}
+
+class munin::client::darwin
+{
+ file { "/usr/share/snmp/snmpd.conf":
+ mode => 744,
+ content => template("munin/darwin_snmpd.conf.erb"),
+ group => staff,
+ owner => root,
+ }
+ delete_matching_line{"startsnmpdno":
+ file => "/etc/hostconfig",
+ pattern => "SNMPSERVER=-NO-",
+ }
+ line { "startsnmpdyes":
+ file => "/etc/hostconfig",
+ line => "SNMPSERVER=-YES-",
+ notify => Exec["/sbin/SystemStarter start SNMP"],
+ }
+ exec{"/sbin/SystemStarter start SNMP":
+ noop => false,
+ }
+ munin::register_snmp { $fqdn: }
+}
+
+class munin::client::debian
+{
+
+ package { "munin-node": ensure => installed }
+
+ file {
+ "/etc/munin/":
+ ensure => directory,
+ mode => 0755, owner => root, group => root;
+ "/etc/munin/munin-node.conf":
+ content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
+ mode => 0644, owner => root, group => root,
+ # this has to be installed before the package, so the postinst can
+ # boot the munin-node without failure!
+ before => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+
+ service { "munin-node":
+ ensure => running,
+ # sarge's munin-node init script has no status
+ hasstatus => $lsbdistcodename ? { sarge => false, default => true }
+ }
+
+ munin::register { $fqdn: }
+
+ # workaround bug in munin_node_configure
+ plugin { "postfix_mailvolume": ensure => absent }
+}
+
diff --git a/manifests/host.pp b/manifests/host.pp
new file mode 100644
index 0000000..f539c9e
--- /dev/null
+++ b/manifests/host.pp
@@ -0,0 +1,39 @@
+# host.pp - the master host of the munin installation
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+class munin::host
+{
+ package { [ "munin", "nmap"]: ensure => installed, }
+
+ File <<| tag == 'munin' |>>
+
+ concatenated_file { "/etc/munin/munin.conf":
+ dir => $NODESDIR,
+ header => "/etc/munin/munin.conf.header",
+ }
+
+ file { ["/var/log/munin-update.log", "/var/log/munin-limits.log",
+ "/var/log/munin-graph.log", "/var/log/munin-html.log"]:
+ ensure => present,
+ mode => 640, owner => munin, group => root;
+ }
+
+}
+
+class munin::snmp_collector
+{
+
+ file {
+ "/var/lib/puppet/modules/munin/create_snmp_links":
+ source => "puppet://$servername/munin/create_snmp_links.sh",
+ mode => 755, owner => root, group => root;
+ }
+
+ exec { "create_snmp_links":
+ command => "/var/lib/puppet/modules/munin/create_snmp_links $NODESDIR",
+ require => File["snmp_links"],
+ timeout => "2048",
+ schedule => daily
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
index c4c4db0..b8fcd6f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,9 +1,17 @@
-#######################################
-# munin module
-# Puzzle ITC - haerry+puppet(at)puzzle.ch
-# GPLv3
-#######################################
+# munin.pp - everything a sitewide munin installation needs
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+# adapted by Puzzle ITC - haerry+puppet(at)puzzle.ch
+#
+# the port is a parameter so vservers can share IP addresses and still be happy
+# Define where the individual nodes' configs are stored
+$NODESDIR="/var/lib/puppet/modules/munin/nodes"
-# modules_dir { "munin": }
-class munin {}
+modules_dir { [ "munin", "munin/nodes", "munin/plugins" ]: }
+
+import "host.pp"
+import "client.pp"
+import "plugin.pp"
+
+include assert_lsbdistcodename
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
new file mode 100644
index 0000000..d143861
--- /dev/null
+++ b/manifests/plugin.pp
@@ -0,0 +1,128 @@
+# plugin.pp - configure a specific munin plugin
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+define munin::plugin (
+ $ensure = "present",
+ $script_path = "/usr/share/munin/plugins",
+ $config = '')
+{
+ debug ( "munin_plugin: name=$name, ensure=$ensure, script_path=$script_path" )
+ $plugin = "/etc/munin/plugins/$name"
+ $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf"
+ case $ensure {
+ "absent": {
+ debug ( "munin_plugin: suppressing $plugin" )
+ file { $plugin: ensure => absent, }
+ }
+ default: {
+ $plugin_src = $ensure ? { "present" => $name, default => $ensure }
+ debug ( "munin_plugin: making $plugin using src: $plugin_src" )
+ file { $plugin:
+ ensure => "$script_path/${plugin_src}",
+ require => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+ }
+ }
+ case $config {
+ '': {
+ debug("no config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ case $ensure {
+ absent: {
+ debug("removing config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ debug("creating $plugin_conf")
+ file { $plugin_conf:
+ content => "[${name}]\n$config\n",
+ mode => 0644, owner => root, group => root,
+ }
+ }
+ }
+ }
+ }
+}
+
+define munin::remoteplugin($ensure = "present", $source, $config = '') {
+ case $ensure {
+ "absent": { munin::plugin{ $name: ensure => absent } }
+ default: {
+ file {
+ "/var/lib/puppet/modules/munin/plugins/${name}":
+ source => $source,
+ mode => 0755, owner => root, group => root;
+ }
+ munin::plugin { $name:
+ ensure => $ensure,
+ config => $config,
+ script_path => "/var/lib/puppet/modules/munin/plugins",
+ }
+ }
+ }
+}
+
+class munin::plugins::base {
+
+ file {
+ [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]:
+ source => "puppet://$servername/munin/empty",
+ ensure => directory, checksum => mtime,
+ recurse => true, purge => true, force => true,
+ mode => 0755, owner => root, group => root,
+ notify => Service[munin-node];
+ "/etc/munin/plugin-conf.d/munin-node":
+ ensure => present,
+ mode => 0644, owner => root, group => root,
+ notify => Service[munin-node],
+ before => Package[munin-node];
+ }
+
+}
+
+# handle if_ and if_err_ plugins
+class munin::plugins::interfaces inherits munin::plugins::base {
+
+ $ifs = gsub(split($interfaces, " "), "(.+)", "if_\\1")
+ $if_errs = gsub(split($interfaces, " "), "(.+)", "if_err_\\1")
+ plugin {
+ $ifs: ensure => "if_";
+ $if_errs: ensure => "if_err_";
+ }
+
+
+}
+
+class munin::plugins::linux inherits munin::plugins::base {
+
+ plugin {
+ [ df_abs, forks, iostat, memory, processes, cpu, df_inode, irqstats,
+ netstat, open_files, swap, df, entropy, interrupts, load, open_inodes,
+ vmstat
+ ]:
+ ensure => present;
+ acpi:
+ ensure => $acpi_available;
+ }
+
+ include munin::plugins::interfaces
+}
+
+class munin::plugins::debian inherits munin::plugins::base {
+
+ plugin { apt_all: ensure => present; }
+
+}
+
+class munin::plugins::vserver inherits munin::plugins::base {
+
+ plugin {
+ [ netstat, processes ]:
+ ensure => present;
+ }
+
+}