summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/client.pp111
-rw-r--r--manifests/host.pp33
-rw-r--r--manifests/init.pp15
-rw-r--r--manifests/munin.pp236
-rw-r--r--manifests/plugin.pp129
5 files changed, 524 insertions, 0 deletions
diff --git a/manifests/client.pp b/manifests/client.pp
new file mode 100644
index 0000000..f52af9f
--- /dev/null
+++ b/manifests/client.pp
@@ -0,0 +1,111 @@
+# 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,
+ 'fqdn' => $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()
+{
+ @@file { "munin_node_${name}": path => "${NODESDIR}/$name",
+ ensure => present,
+ content => template("munin/defaultclient.erb"),
+ }
+}
+
+define munin::register_snmp()
+{
+ @@file { "munin_snmp_${name}": path => "${NODESDIR}/$name",
+ ensure => present,
+ content => template("munin/snmpclient.erb"),
+ }
+}
+
+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-",
+ }
+ append_if_no_such_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
+{
+ err("munin port: $munin_port_real" )
+ err("munin host: $munin_host_real" )
+
+ package { "munin-node": ensure => installed }
+
+ file {
+ "/etc/munin/munin-node.conf":
+ content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
+ mode => 0644, owner => root, group => root,
+ require => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+
+ service { "munin-node":
+ ensure => running,
+ hasstatus => true,
+ }
+
+ munin::register { $munin_host_real: }
+
+ # 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..d790b4a
--- /dev/null
+++ b/manifests/host.pp
@@ -0,0 +1,33 @@
+# 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 <<||>>
+
+ concatenated_file { "/etc/munin/munin.conf":
+ dir => "/var/lib/puppet/modules/munin/nodes/",
+ header => "/etc/munin/munin.conf.header",
+ }
+
+}
+
+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
new file mode 100644
index 0000000..dc646e7
--- /dev/null
+++ b/manifests/init.pp
@@ -0,0 +1,15 @@
+# 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.
+
+# 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", "munin/nodes" ]: }
+
+import "host.pp"
+import "client.pp"
+import "plugin.pp"
+
diff --git a/manifests/munin.pp b/manifests/munin.pp
new file mode 100644
index 0000000..a19a26f
--- /dev/null
+++ b/manifests/munin.pp
@@ -0,0 +1,236 @@
+# 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.
+
+# 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/local/puppet/munin-nodes"
+
+class munin {
+
+class default_client { munin::client { default_munin_node: } }
+class default_vserver_client { munin::vserver_client { vserver_munin_node: } }
+
+define client ($port = 4949, $bindhost = "fqdn")
+{
+ munin::plugin {
+ apt: ensure => absent;
+ # needs patch for xen-hosts
+ iostat: script_path => "/usr/local/bin";
+ # others
+ [ apt_all, df_abs ]: ;
+ }
+
+ munin::base { base:
+ port => $port,
+ bindhost => $bindhost,
+ }
+}
+
+define vserver_client ($port = 4950, $bindhost = "fqdn")
+{
+ munin::plugin {
+ [
+ apt, cpu, df, df_abs, df_inode, entropy, forks, interrupts, iostat,
+ irqstats, load, memory, open_files, open_inodes, swap
+ ]:
+ ensure => absent;
+ [ apt_all, netstat, processes]: ;
+ }
+
+ munin::base { base:
+ port => $port,
+ bindhost => $bindhost,
+ }
+}
+
+define base ($port = 4949, $bindhost = "fqdn")
+{
+ package { "munin-node":
+ ensure => installed,
+ require => [ User[munin], Group[munin] ]
+ }
+
+ user { munin:
+ uid => 203,
+ gid => 203,
+ home => "/var/lib/munin",
+ shell => "/bin/false",
+ allowdupe => false,
+ }
+
+ group { munin:
+ gid => 203,
+ allowdupe => false,
+ }
+
+ file {
+ ["/var/lib/munin", "/var/lib/munin/plugin-state" ]:
+ ensure => directory,
+ owner => munin, group => munin;
+ "/var/run/munin":
+ ensure => directory,
+ owner => munin;
+ "/var/log/munin":
+ ensure => directory,
+ owner => munin, group => adm;
+ }
+
+ replace { set_munin_node_port:
+ file => "/etc/munin/munin-node.conf",
+ pattern => "^port (?!$port)[0-9]*.*",
+ replacement => "port $port",
+ notify => Service[munin-node],
+ require => Package[munin-node],
+ }
+
+ $real_bindhost = $bindhost ? {
+ "fqdn" => $fqdn,
+ default => $bindhost
+ }
+ debug("Using bindhost $real_bindhost for $fqdn")
+
+ replace { set_munin_node_bindhost:
+ file => "/etc/munin/munin-node.conf",
+ pattern => "^host (?!$real_bindhost).*",
+ replacement => "host $real_bindhost",
+ notify => Service[munin-node],
+ require => Package[munin-node],
+ }
+
+ line { allow_munin_host:
+ file => "/etc/munin/munin-node.conf",
+ line => "allow ^$munin_host$",
+ ensure => present,
+ notify => Service[munin-node],
+ require => Package[munin-node],
+ }
+
+ line { set_fqdn:
+ file => "/etc/munin/munin-node.conf",
+ line => "host_name $fqdn",
+ ensure => present,
+ notify => Service[munin-node],
+ require => Package[munin-node],
+ }
+
+ @@file { "munin_def_${real_bindhost}_$port": path => "${NODESDIR}/$fqdn",
+ ensure => present,
+ content => "[$fqdn]\n\taddress $real_bindhost\n\tport $port\n\texim_mailstats.graph_period minute\n\n",
+ }
+
+ # TODO: das funktioniert noch nicht g'scheit
+ file {
+ [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d"] :
+ checksum => mtime, ensure => directory,
+ require => Package[munin-node],
+ notify => Service[munin-node];
+ "/etc/munin/munin-node.conf":
+ checksum => md5,
+ require => Package[munin-node],
+ }
+
+ service { munin-node:
+ ensure => running,
+ subscribe => [ Package["munin-node"],
+ File["/etc/munin/munin-node.conf"],
+ Exec[exec_set_munin_node_bindhost],
+ Exec[exec_set_munin_node_port],
+ User[munin], Group[munin] ],
+ }
+
+ # workaround bug in munin_node_configure
+ munin::plugin { postfix_mailvolume: ensure => absent }
+}
+
+
+class host {
+ err("$fqdn: include inetd")
+ package { [munin, micro-httpd]:
+ ensure => installed
+ }
+ append_if_no_such_line { micro-httpd:
+ file => "/etc/inetd.conf",
+ line => "micro_http_munin stream tcp nowait.800 nobody /usr/sbin/micro_httpd micro_httpd_munin /var/www/munin/",
+ require => Package[micro-httpd],
+ }
+ append_if_no_such_line { micro-http-munin-port:
+ file => "/etc/services",
+ line => "micro_http_munin 81/tcp",
+ }
+
+ File <<||>>
+
+ # monitor this file for updates
+ $munin_includes = "$splice_dir/munin_conf_includes"
+ file { $munin_includes: checksum => md5, }
+
+ exec { create_munin_includes:
+ command => "/bin/sh -c '/bin/cat $NODESDIR/* > $munin_includes'",
+ subscribe => File[$NODESDIR]
+ }
+
+ # create munin.conf
+ file_splice { munin_conf_includes:
+ file => "/etc/munin/munin.conf",
+ input_file => "$splice_dir/munin_conf_includes",
+ require => Exec[create_munin_includes],
+ subscribe => File[$munin_includes],
+ }
+
+
+}
+
+define 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"
+ case $ensure {
+ "absent": {
+ debug ( "munin_plugin: suppressing $plugin" )
+ }
+ "present": {
+ debug ( "munin_plugin: making $plugin using default $name" )
+ file {
+ $plugin:
+ ensure => "$script_path/$name",
+ require => Package[munin-node],
+ notify => Service[munin-node],
+ }
+ }
+ default: {
+ debug ( "munin_plugin: making $plugin using $ensure" )
+ file {
+ $plugin:
+ ensure => "$script_path/$ensure",
+ 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,
+ }
+ }
+ }
+ }
+ }
+}
+
+
+}
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
new file mode 100644
index 0000000..8b85e63
--- /dev/null
+++ b/manifests/plugin.pp
@@ -0,0 +1,129 @@
+# 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];
+ }
+
+ puppet::fact{ interfaces:
+ source => "puppet://$servername/munin/facter/interfaces.rb",
+ require => Package[iproute],
+ }
+}
+
+# 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;
+ }
+
+ 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, vmstat ]:
+ ensure => present;
+ }
+
+}