summaryrefslogtreecommitdiff
path: root/manifests/client.pp
blob: 818184537699d98870bfbfbcbcd4f40fed52e1c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# 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
		}
		gentoo: {
			include munin::client::gentoo
			include munin::plugins::gentoo
		}
		centos: {
			include munin::client::centos
			include munin::plugins::centos
		}
		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
				}
			}
		}
		default: {
			err( "Don't know which munin plugins to install for $kernel" )
		}
	}
	case $virtual {
        physical: { include munin::plugins::physical }
	    xen0: { include munin::plugins::dom0 }
        xenu: { include munin::plugins::domU }
    }

}

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  => 0,
		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 }
    # the plugin will need that
	package { "iproute": ensure => installed }

	file {
		"/etc/munin/":
			ensure => directory,
			mode => 0755, owner => root, group => 0;
		"/etc/munin/munin-node.conf":
			content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
			mode => 0644, owner => root, group => 0,
			# 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
	munin::plugin { "postfix_mailvolume": ensure => absent }
}

class munin::client::gentoo 
{
    $acpi_available = "absent"
    package { 'munin-node':
                name => 'munin',
                ensure => present,
                category => $operatingsystem ? {
                        gentoo => 'net-analyzer',
                        default => '',
                },
    }

	file {
		"/etc/munin/":
			ensure => directory,
			mode => 0755, owner => root, group => 0;
		"/etc/munin/munin-node.conf":
			content => template("munin/munin-node.conf.Gentoo."),
			mode => 0644, owner => root, group => 0,
			# 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"],
	}

	service { "munin-node":
		ensure => running, 
	}

	munin::register { $fqdn: }
}

class munin::client::centos 
{
    package { 'munin-node':
                ensure => present,
    }


	file {
		"/etc/munin/":
			ensure => directory,
			mode => 0755, owner => root, group =>0;
		"/etc/munin/munin-node.conf":
			content => template("munin/munin-node.conf.CentOS."),
			mode => 0644, owner => root, group => 0,
			# 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, 
	}

	munin::register { $fqdn: }

}