summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwoud Kohl van Wijngaarden <e.kohlvanwijngaarden@oxilion.nl>2013-07-02 22:49:02 +0200
committerEwoud Kohl van Wijngaarden <e.kohlvanwijngaarden@oxilion.nl>2013-11-20 14:34:32 +0100
commit057658ba93e2562c596dfa5607836679631be916 (patch)
tree43d9398cbcd950553f59676a36740ffe316999ad
parent99782a1f6446e5fee1670e832f22731aef77d2f6 (diff)
Unify OS specific munin-conf.conf
In essence all munin-node.conf files contained the same template, besides a few values. By moving all to a single template, maintenance burden is reduced. To ensure all values are still present in the templates, tests are added.
-rw-r--r--manifests/client/base.pp4
-rw-r--r--manifests/client/debian.pp3
-rw-r--r--manifests/client/params.pp19
-rw-r--r--spec/classes/munin_client_base_spec.rb86
l---------templates/munin-node.conf.CentOS1
l---------templates/munin-node.conf.CentOS.1
l---------templates/munin-node.conf.CentOS.51
l---------templates/munin-node.conf.Debian1
-rw-r--r--templates/munin-node.conf.Debian.etch39
l---------templates/munin-node.conf.Debian.feisty1
l---------templates/munin-node.conf.Debian.gutsy1
l---------templates/munin-node.conf.Debian.hardy1
-rw-r--r--templates/munin-node.conf.Debian.lenny39
l---------templates/munin-node.conf.Debian.lucid1
l---------templates/munin-node.conf.Debian.sarge1
l---------templates/munin-node.conf.Debian.sid1
l---------templates/munin-node.conf.Debian.squeeze1
-rw-r--r--templates/munin-node.conf.Debian.wheezy57
l---------templates/munin-node.conf.Gentoo1
l---------templates/munin-node.conf.Gentoo.1
-rw-r--r--templates/munin-node.conf.OpenBSD59
-rw-r--r--templates/munin-node.conf.Ubuntu39
l---------templates/munin-node.conf.Ubuntu.precise1
l---------templates/munin-node.conf.Ubuntu.quantal1
-rw-r--r--templates/munin-node.conf.erb (renamed from templates/munin-node.conf.default)15
-rw-r--r--templates/site.conf9
26 files changed, 111 insertions, 273 deletions
diff --git a/manifests/client/base.pp b/manifests/client/base.pp
index e81028d..71531fa 100644
--- a/manifests/client/base.pp
+++ b/manifests/client/base.pp
@@ -1,5 +1,5 @@
# Install a basic munin client
-class munin::client::base {
+class munin::client::base inherits munin::client::params {
package { 'munin-node':
ensure => installed
}
@@ -17,7 +17,7 @@ class munin::client::base {
group => 0,
}
file {'/etc/munin/munin-node.conf':
- content => template("munin/munin-node.conf.${::operatingsystem}"),
+ content => template("${module_name}/munin-node.conf.erb"),
# this has to be installed before the package, so the postinst can
# boot the munin-node without failure!
before => Package['munin-node'],
diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp
index 63a0e14..f1bbb3c 100644
--- a/manifests/client/debian.pp
+++ b/manifests/client/debian.pp
@@ -12,9 +12,6 @@ class munin::client::debian inherits munin::client::base {
# sarge's munin-node init script has no status
hasstatus => $hasstatus
}
- File['/etc/munin/munin-node.conf']{
- content => template("munin/munin-node.conf.${::operatingsystem}.${::lsbdistcodename}"),
- }
# workaround bug in munin_node_configure
plugin { 'postfix_mailvolume': ensure => absent }
include munin::plugins::debian
diff --git a/manifests/client/params.pp b/manifests/client/params.pp
new file mode 100644
index 0000000..14d3749
--- /dev/null
+++ b/manifests/client/params.pp
@@ -0,0 +1,19 @@
+# Set the parameters for the munin client
+class munin::client::params {
+ $user = 'root'
+
+ case $::operatingsystem {
+ 'OpenBSD': {
+ $group = '0'
+ $log_file = '/var/log/munin-node/munin-node.log'
+ }
+ 'Debian': {
+ $group = 'root'
+ $log_file = '/var/log/munin/munin-node.log'
+ }
+ default: {
+ $group = 'root'
+ $log_file = '/var/log/munin-node/munin-node.log'
+ }
+ }
+}
diff --git a/spec/classes/munin_client_base_spec.rb b/spec/classes/munin_client_base_spec.rb
new file mode 100644
index 0000000..1b3d936
--- /dev/null
+++ b/spec/classes/munin_client_base_spec.rb
@@ -0,0 +1,86 @@
+require 'spec_helper'
+
+describe 'munin::client::base' do
+ let :default_facts do
+ {
+ :fqdn => 'munin-node.example.org',
+ }
+ end
+
+ let :pre_condition do
+ 'include munin::client'
+ end
+
+ context 'on Debian' do
+ let :facts do
+ { :operatingsystem => 'Debian' }.merge(default_facts)
+ end
+
+ it 'should compile' do
+ should include_class('munin::client::base')
+ end
+
+ it 'should set up munin-node' do
+ should contain_service('munin-node').with({
+ :ensure => 'running',
+ :enable => true,
+ :hasstatus => true,
+ :hasrestart => true,
+ })
+
+ should contain_file('/etc/munin').with({
+ :ensure => 'directory',
+ :mode => '0755',
+ :owner => 'root',
+ :group => 0,
+ })
+
+ should contain_file('/etc/munin/munin-node.conf').
+ with_content(/^host_name munin-node.example.org$/).
+ with_content(/^allow \^127\\\.0\\\.0\\\.1\$$/).
+ with_content(/^host \*$/).
+ with_content(/^port 4949$/)
+
+ should contain_munin__register('munin-node.example.org').with({
+ :host => 'munin-node.example.org',
+ :port => '4949',
+ :use_ssh => false,
+ :config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'],
+ :export_tag => 'munin',
+ })
+
+ should contain_class('munin::plugins::base')
+ end
+
+ it 'should contain the Debian specific values' do
+ should contain_file('/etc/munin/munin-node.conf').
+ with_content(/^log_file \/var\/log\/munin\/munin-node.log$/).
+ with_content(/^group root$/)
+ end
+ end
+
+ context 'on CentOS' do
+ let :facts do
+ { :operatingsystem => 'CentOS' }.merge(default_facts)
+ end
+
+ it 'should contain the CentOS specific values' do
+ should contain_file('/etc/munin/munin-node.conf').
+ with_content(/^log_file \/var\/log\/munin-node\/munin-node.log$/).
+ with_content(/^group root$/)
+ end
+ end
+
+ # Disabled because the required openbsd module is not in the requirements
+ context 'on OpenBSD', :if => false do
+ let :facts do
+ { :operatingsystem => 'OpenBSD' }.merge(default_facts)
+ end
+
+ it 'should contain the config OpenBSD specific values' do
+ should contain_file('/etc/munin/munin-node.conf').
+ with_content(/^log_file \/var\/log\/munin-node\/munin-node.log$/).
+ with_content(/^group 0$/)
+ end
+ end
+end
diff --git a/templates/munin-node.conf.CentOS b/templates/munin-node.conf.CentOS
deleted file mode 120000
index 082b30c..0000000
--- a/templates/munin-node.conf.CentOS
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.default \ No newline at end of file
diff --git a/templates/munin-node.conf.CentOS. b/templates/munin-node.conf.CentOS.
deleted file mode 120000
index 082b30c..0000000
--- a/templates/munin-node.conf.CentOS.
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.default \ No newline at end of file
diff --git a/templates/munin-node.conf.CentOS.5 b/templates/munin-node.conf.CentOS.5
deleted file mode 120000
index 082b30c..0000000
--- a/templates/munin-node.conf.CentOS.5
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.default \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian b/templates/munin-node.conf.Debian
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch
deleted file mode 100644
index 9763772..0000000
--- a/templates/munin-node.conf.Debian.etch
+++ /dev/null
@@ -1,39 +0,0 @@
-##########
-########## Managed by puppet
-##########
-
-log_level 4
-log_file /var/log/munin/munin-node.log
-pid_file /var/run/munin/munin-node.pid
-background 1
-setseid 1
-
-# Which host/port to bind to;
-host <%= scope.lookupvar('munin::client::host') %>
-port <%= scope.lookupvar('munin::client::port') %>
-user root
-group root
-setsid yes
-
-# Regexps for files to ignore
-
-ignore_file ~$
-ignore_file \.bak$
-ignore_file %$
-ignore_file \.dpkg-(tmp|new|old|dist)$
-ignore_file \.rpm(save|new)$
-
-# Set this if the client doesn't report the correct hostname when
-# telnetting to localhost, port 4949
-#
-#host_name localhost.localdomain
-host_name <%= scope.lookupvar('::fqdn') %>
-
-# A list of addresses that are allowed to connect. This must be a
-# regular expression, due to brain damage in Net::Server, which
-# doesn't understand CIDR-style network notation. You may repeat
-# the allow line as many times as you'd like
-<% scope.lookupvar('munin::client::allow').each do |allow| -%>
-allow <%= "^#{Regexp.escape(allow)}$" %>
-<% end -%>
-
diff --git a/templates/munin-node.conf.Debian.feisty b/templates/munin-node.conf.Debian.feisty
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian.feisty
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.gutsy b/templates/munin-node.conf.Debian.gutsy
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian.gutsy
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.hardy b/templates/munin-node.conf.Debian.hardy
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian.hardy
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.lenny b/templates/munin-node.conf.Debian.lenny
deleted file mode 100644
index 9763772..0000000
--- a/templates/munin-node.conf.Debian.lenny
+++ /dev/null
@@ -1,39 +0,0 @@
-##########
-########## Managed by puppet
-##########
-
-log_level 4
-log_file /var/log/munin/munin-node.log
-pid_file /var/run/munin/munin-node.pid
-background 1
-setseid 1
-
-# Which host/port to bind to;
-host <%= scope.lookupvar('munin::client::host') %>
-port <%= scope.lookupvar('munin::client::port') %>
-user root
-group root
-setsid yes
-
-# Regexps for files to ignore
-
-ignore_file ~$
-ignore_file \.bak$
-ignore_file %$
-ignore_file \.dpkg-(tmp|new|old|dist)$
-ignore_file \.rpm(save|new)$
-
-# Set this if the client doesn't report the correct hostname when
-# telnetting to localhost, port 4949
-#
-#host_name localhost.localdomain
-host_name <%= scope.lookupvar('::fqdn') %>
-
-# A list of addresses that are allowed to connect. This must be a
-# regular expression, due to brain damage in Net::Server, which
-# doesn't understand CIDR-style network notation. You may repeat
-# the allow line as many times as you'd like
-<% scope.lookupvar('munin::client::allow').each do |allow| -%>
-allow <%= "^#{Regexp.escape(allow)}$" %>
-<% end -%>
-
diff --git a/templates/munin-node.conf.Debian.lucid b/templates/munin-node.conf.Debian.lucid
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian.lucid
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.sarge b/templates/munin-node.conf.Debian.sarge
deleted file mode 120000
index e0646b9..0000000
--- a/templates/munin-node.conf.Debian.sarge
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.sid b/templates/munin-node.conf.Debian.sid
deleted file mode 120000
index 6b8d690..0000000
--- a/templates/munin-node.conf.Debian.sid
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.lenny \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.squeeze b/templates/munin-node.conf.Debian.squeeze
deleted file mode 120000
index 6b8d690..0000000
--- a/templates/munin-node.conf.Debian.squeeze
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Debian.lenny \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.wheezy b/templates/munin-node.conf.Debian.wheezy
deleted file mode 100644
index fe6f27f..0000000
--- a/templates/munin-node.conf.Debian.wheezy
+++ /dev/null
@@ -1,57 +0,0 @@
-##########
-########## Managed by puppet
-##########
-
-log_level 4
-log_file /var/log/munin/munin-node.log
-pid_file /var/run/munin/munin-node.pid
-
-background 1
-setsid 1
-
-user root
-group root
-
-# Regexps for files to ignore
-
-ignore_file ~$
-#ignore_file [#~]$ # FIX doesn't work. '#' starts a comment
-ignore_file DEADJOE$
-ignore_file \.bak$
-ignore_file %$
-ignore_file \.dpkg-(tmp|new|old|dist)$
-ignore_file \.rpm(save|new)$
-ignore_file \.pod$
-
-# Set this if the client doesn't report the correct hostname when
-# telnetting to localhost, port 4949
-#
-#host_name localhost.localdomain
-host_name <%= scope.lookupvar('::fqdn') %>
-
-# A list of addresses that are allowed to connect. This must be a
-# regular expression, since Net::Server does not understand CIDR-style
-# network notation unless the perl module Net::CIDR is installed. You
-# may repeat the allow line as many times as you'd like
-
-<% scope.lookupvar('munin::client::allow').each do |allow| -%>
-allow <%= "^#{Regexp.escape(allow)}$" %>
-<% end -%>
-
-# If you have installed the Net::CIDR perl module, you can use one or more
-# cidr_allow and cidr_deny address/mask patterns. A connecting client must
-# match any cidr_allow, and not match any cidr_deny. Note that a netmask
-# *must* be provided, even if it's /32
-#
-# Example:
-#
-# cidr_allow 127.0.0.1/32
-# cidr_allow 192.0.2.0/24
-# cidr_deny 192.0.2.42/32
-
-# Which address to bind to;
-host <%= scope.lookupvar('munin::client::host') %>
-
-# And which port
-port <%= scope.lookupvar('munin::client::port') %>
-
diff --git a/templates/munin-node.conf.Gentoo b/templates/munin-node.conf.Gentoo
deleted file mode 120000
index 082b30c..0000000
--- a/templates/munin-node.conf.Gentoo
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.default \ No newline at end of file
diff --git a/templates/munin-node.conf.Gentoo. b/templates/munin-node.conf.Gentoo.
deleted file mode 120000
index fd16e50..0000000
--- a/templates/munin-node.conf.Gentoo.
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Gentoo \ No newline at end of file
diff --git a/templates/munin-node.conf.OpenBSD b/templates/munin-node.conf.OpenBSD
deleted file mode 100644
index 14b658e..0000000
--- a/templates/munin-node.conf.OpenBSD
+++ /dev/null
@@ -1,59 +0,0 @@
-##########
-########## Managed by puppet
-##########
-#
-# Example config-file for munin-node
-#
-
-log_level 4
-log_file /var/log/munin/munin-node.log
-pid_file /var/run/munin/munin-node.pid
-
-background 1
-setsid 1
-
-user root
-group 0
-
-# Regexps for files to ignore
-ignore_file ~$
-ignore_file DEADJOE$
-ignore_file \.bak$
-ignore_file %$
-ignore_file \.dpkg-(tmp|new|old|dist)$
-ignore_file \.rpm(save|new)$
-ignore_file \.pod$
-
-# Set this if the client doesn't report the correct hostname when
-# telnetting to localhost, port 4949
-#
-#host_name localhost.localdomain
-host_name <%= scope.lookupvar('::fqdn') %>
-
-# A list of addresses that are allowed to connect. This must be a
-# regular expression, since Net::Server does not understand CIDR-style
-# network notation unless the perl module Net::CIDR is installed. You
-# may repeat the allow line as many times as you'd like
-
-<% scope.lookupvar('munin::client::allow').each do |allow| -%>
-allow <%= "^#{Regexp.escape(allow)}$" %>
-<% end -%>
-
-# If you have installed the Net::CIDR perl module, you can use one or more
-# cidr_allow and cidr_deny address/mask patterns. A connecting client must
-# match any cidr_allow, and not match any cidr_deny. Note that a netmask
-# *must* be provided, even if it's /32
-#
-# Example:
-#
-# cidr_allow 127.0.0.1/32
-# cidr_allow 192.0.2.0/24
-# cidr_deny 192.0.2.42/32
-
-# Which address to bind to;
-host <%= scope.lookupvar('munin::client::host') %>
-# host 127.0.0.1
-
-# And which port
-port <%= scope.lookupvar('munin::client::port') %>
-
diff --git a/templates/munin-node.conf.Ubuntu b/templates/munin-node.conf.Ubuntu
deleted file mode 100644
index 9763772..0000000
--- a/templates/munin-node.conf.Ubuntu
+++ /dev/null
@@ -1,39 +0,0 @@
-##########
-########## Managed by puppet
-##########
-
-log_level 4
-log_file /var/log/munin/munin-node.log
-pid_file /var/run/munin/munin-node.pid
-background 1
-setseid 1
-
-# Which host/port to bind to;
-host <%= scope.lookupvar('munin::client::host') %>
-port <%= scope.lookupvar('munin::client::port') %>
-user root
-group root
-setsid yes
-
-# Regexps for files to ignore
-
-ignore_file ~$
-ignore_file \.bak$
-ignore_file %$
-ignore_file \.dpkg-(tmp|new|old|dist)$
-ignore_file \.rpm(save|new)$
-
-# Set this if the client doesn't report the correct hostname when
-# telnetting to localhost, port 4949
-#
-#host_name localhost.localdomain
-host_name <%= scope.lookupvar('::fqdn') %>
-
-# A list of addresses that are allowed to connect. This must be a
-# regular expression, due to brain damage in Net::Server, which
-# doesn't understand CIDR-style network notation. You may repeat
-# the allow line as many times as you'd like
-<% scope.lookupvar('munin::client::allow').each do |allow| -%>
-allow <%= "^#{Regexp.escape(allow)}$" %>
-<% end -%>
-
diff --git a/templates/munin-node.conf.Ubuntu.precise b/templates/munin-node.conf.Ubuntu.precise
deleted file mode 120000
index d8fcb24..0000000
--- a/templates/munin-node.conf.Ubuntu.precise
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Ubuntu \ No newline at end of file
diff --git a/templates/munin-node.conf.Ubuntu.quantal b/templates/munin-node.conf.Ubuntu.quantal
deleted file mode 120000
index d8fcb24..0000000
--- a/templates/munin-node.conf.Ubuntu.quantal
+++ /dev/null
@@ -1 +0,0 @@
-munin-node.conf.Ubuntu \ No newline at end of file
diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.erb
index dc7c4fc..5e015d2 100644
--- a/templates/munin-node.conf.default
+++ b/templates/munin-node.conf.erb
@@ -1,19 +1,16 @@
##########
########## Managed by puppet
##########
-#
-# Example config-file for munin-node
-#
log_level 4
-log_file /var/log/munin-node/munin-node.log
+log_file <%= @log_file %>
pid_file /var/run/munin/munin-node.pid
background 1
setsid 1
-user root
-group 0
+user <%= @user %>
+group <%= @group %>
# This is the timeout for the whole transaction.
# Units are in sec. Default is 15 min
@@ -37,14 +34,12 @@ ignore_file \.pod$
# Set this if the client doesn't report the correct hostname when
# telnetting to localhost, port 4949
#
-#host_name localhost.localdomain
-host_name <%= @fqdn %>
+host_name <%= scope.lookupvar('::fqdn') %>
# A list of addresses that are allowed to connect. This must be a
# regular expression, since Net::Server does not understand CIDR-style
# network notation unless the perl module Net::CIDR is installed. You
# may repeat the allow line as many times as you'd like
-
<% scope.lookupvar('munin::client::allow').each do |allow| -%>
allow <%= "^#{Regexp.escape(allow)}$" %>
<% end -%>
@@ -62,8 +57,6 @@ allow <%= "^#{Regexp.escape(allow)}$" %>
# Which address to bind to;
host <%= scope.lookupvar('munin::client::host') %>
-# host 127.0.0.1
# And which port
port <%= scope.lookupvar('munin::client::port') %>
-
diff --git a/templates/site.conf b/templates/site.conf
deleted file mode 100644
index 842bde0..0000000
--- a/templates/site.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-<VirtualHost *>
- ServerName <%= @name %>
- DocumentRoot /var/cache/munin/www/
- <Location />
- order allow,deny
- Allow from all
- </Location>
-</VirtualHost>
-