From 057658ba93e2562c596dfa5607836679631be916 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 22:49:02 +0200 Subject: 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. --- manifests/client/base.pp | 4 +- manifests/client/debian.pp | 3 -- manifests/client/params.pp | 19 +++++++ spec/classes/munin_client_base_spec.rb | 86 ++++++++++++++++++++++++++++++++ templates/munin-node.conf.CentOS | 1 - templates/munin-node.conf.CentOS. | 1 - templates/munin-node.conf.CentOS.5 | 1 - templates/munin-node.conf.Debian | 1 - templates/munin-node.conf.Debian.etch | 39 --------------- templates/munin-node.conf.Debian.feisty | 1 - templates/munin-node.conf.Debian.gutsy | 1 - templates/munin-node.conf.Debian.hardy | 1 - templates/munin-node.conf.Debian.lenny | 39 --------------- templates/munin-node.conf.Debian.lucid | 1 - templates/munin-node.conf.Debian.sarge | 1 - templates/munin-node.conf.Debian.sid | 1 - templates/munin-node.conf.Debian.squeeze | 1 - templates/munin-node.conf.Debian.wheezy | 57 --------------------- templates/munin-node.conf.Gentoo | 1 - templates/munin-node.conf.Gentoo. | 1 - templates/munin-node.conf.OpenBSD | 59 ---------------------- templates/munin-node.conf.Ubuntu | 39 --------------- templates/munin-node.conf.Ubuntu.precise | 1 - templates/munin-node.conf.Ubuntu.quantal | 1 - templates/munin-node.conf.default | 69 ------------------------- templates/munin-node.conf.erb | 62 +++++++++++++++++++++++ templates/site.conf | 9 ---- 27 files changed, 169 insertions(+), 331 deletions(-) create mode 100644 manifests/client/params.pp create mode 100644 spec/classes/munin_client_base_spec.rb delete mode 120000 templates/munin-node.conf.CentOS delete mode 120000 templates/munin-node.conf.CentOS. delete mode 120000 templates/munin-node.conf.CentOS.5 delete mode 120000 templates/munin-node.conf.Debian delete mode 100644 templates/munin-node.conf.Debian.etch delete mode 120000 templates/munin-node.conf.Debian.feisty delete mode 120000 templates/munin-node.conf.Debian.gutsy delete mode 120000 templates/munin-node.conf.Debian.hardy delete mode 100644 templates/munin-node.conf.Debian.lenny delete mode 120000 templates/munin-node.conf.Debian.lucid delete mode 120000 templates/munin-node.conf.Debian.sarge delete mode 120000 templates/munin-node.conf.Debian.sid delete mode 120000 templates/munin-node.conf.Debian.squeeze delete mode 100644 templates/munin-node.conf.Debian.wheezy delete mode 120000 templates/munin-node.conf.Gentoo delete mode 120000 templates/munin-node.conf.Gentoo. delete mode 100644 templates/munin-node.conf.OpenBSD delete mode 100644 templates/munin-node.conf.Ubuntu delete mode 120000 templates/munin-node.conf.Ubuntu.precise delete mode 120000 templates/munin-node.conf.Ubuntu.quantal delete mode 100644 templates/munin-node.conf.default create mode 100644 templates/munin-node.conf.erb delete mode 100644 templates/site.conf 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.default deleted file mode 100644 index dc7c4fc..0000000 --- a/templates/munin-node.conf.default +++ /dev/null @@ -1,69 +0,0 @@ -########## -########## Managed by puppet -########## -# -# Example config-file for munin-node -# - -log_level 4 -log_file /var/log/munin-node/munin-node.log -pid_file /var/run/munin/munin-node.pid - -background 1 -setsid 1 - -user root -group 0 - -# This is the timeout for the whole transaction. -# Units are in sec. Default is 15 min -# -# global_timeout 900 - -# This is the timeout for each plugin. -# Units are in sec. Default is 1 min -# -# timeout 60 - -# 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 <%= @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.erb b/templates/munin-node.conf.erb new file mode 100644 index 0000000..5e015d2 --- /dev/null +++ b/templates/munin-node.conf.erb @@ -0,0 +1,62 @@ +########## +########## Managed by puppet +########## + +log_level 4 +log_file <%= @log_file %> +pid_file /var/run/munin/munin-node.pid + +background 1 +setsid 1 + +user <%= @user %> +group <%= @group %> + +# This is the timeout for the whole transaction. +# Units are in sec. Default is 15 min +# +# global_timeout 900 + +# This is the timeout for each plugin. +# Units are in sec. Default is 1 min +# +# timeout 60 + +# 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 <%= 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/site.conf b/templates/site.conf deleted file mode 100644 index 842bde0..0000000 --- a/templates/site.conf +++ /dev/null @@ -1,9 +0,0 @@ - - ServerName <%= @name %> - DocumentRoot /var/cache/munin/www/ - - order allow,deny - Allow from all - - - -- cgit v1.2.3 From 9bee8a31f2305dda884aeab3caf3bf91cd8603ba Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 23:07:00 +0200 Subject: Unify logrotate files into templates --- files/config/host/logrotate.CentOS | 35 ----------------------- files/config/host/logrotate.Debian | 35 ----------------------- manifests/host/cgi.pp | 12 +++----- spec/classes/munin_host_cgi_spec.rb | 57 +++++++++++++++++++++++++++++++++++++ templates/logrotate.conf.erb | 35 +++++++++++++++++++++++ 5 files changed, 96 insertions(+), 78 deletions(-) delete mode 100644 files/config/host/logrotate.CentOS delete mode 100644 files/config/host/logrotate.Debian create mode 100644 spec/classes/munin_host_cgi_spec.rb create mode 100644 templates/logrotate.conf.erb diff --git a/files/config/host/logrotate.CentOS b/files/config/host/logrotate.CentOS deleted file mode 100644 index 411de3f..0000000 --- a/files/config/host/logrotate.CentOS +++ /dev/null @@ -1,35 +0,0 @@ -/var/log/munin/munin-update.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} - -/var/log/munin/munin-graph.log { - daily - missingok - rotate 7 - compress - notifempty - create 660 munin apache -} - -/var/log/munin/munin-html.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} - -/var/log/munin/munin-limits.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} diff --git a/files/config/host/logrotate.Debian b/files/config/host/logrotate.Debian deleted file mode 100644 index 732c871..0000000 --- a/files/config/host/logrotate.Debian +++ /dev/null @@ -1,35 +0,0 @@ -/var/log/munin/munin-update.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} - -/var/log/munin/munin-graph.log { - daily - missingok - rotate 7 - compress - notifempty - create 660 munin www-data -} - -/var/log/munin/munin-html.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} - -/var/log/munin/munin-limits.log { - daily - missingok - rotate 7 - compress - notifempty - create 640 munin adm -} diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 5b0ecbb..9951a48 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -30,13 +30,9 @@ class munin::host::cgi( } file{'/etc/logrotate.d/munin': - source => [ "puppet:///modules/site_munin/config/host/${::fqdn}/logrotate", - "puppet:///modules/site_munin/config/host/logrotate.${::operatingsystem}", - 'puppet:///modules/site_munin/config/host/logrotate', - "puppet:///modules/munin/config/host/logrotate.${::operatingsystem}", - 'puppet:///modules/munin/config/host/logrotate' ], - owner => root, - group => 0, - mode => '0644', + content => template("${module_name}/logrotate.conf.erb"), + owner => root, + group => 0, + mode => '0644', } } diff --git a/spec/classes/munin_host_cgi_spec.rb b/spec/classes/munin_host_cgi_spec.rb new file mode 100644 index 0000000..301f964 --- /dev/null +++ b/spec/classes/munin_host_cgi_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'munin::host::cgi' do + #let :pre_condition do + # 'include munin::client' + #end + + context 'on Debian' do + let :facts do + { :operatingsystem => 'Debian' } + end + + it 'should compile' do + should include_class('munin::host::cgi') + end + + it 'should exec set_modes_for_cgi' do + should contain_exec('set_modes_for_cgi').with({ + :command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/munin/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/www/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + :refreshonly => true, + :subscribe => 'Concat::Fragment[munin.conf.header]', + }) + end + + it 'should contain logrotate.conf' do + should contain_file('/etc/logrotate.d/munin').with({ + :content => /^ create 660 munin www-data$/, + :group => 0, + :mode => '0644', + :owner => 'root', + }) + end + end + + context 'on CentOS' do + let :facts do + { :operatingsystem => 'CentOS' } + end + + it 'should exec set_modes_for_cgi' do + should contain_exec('set_modes_for_cgi').with({ + :command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + :refreshonly => true, + :subscribe => 'Concat::Fragment[munin.conf.header]', + }) + end + + it 'should contain logrotate.conf' do + should contain_file('/etc/logrotate.d/munin').with({ + :content => /^ create 660 munin apache$/, + :group => 0, + :mode => '0644', + :owner => 'root', + }) + end + end +end diff --git a/templates/logrotate.conf.erb b/templates/logrotate.conf.erb new file mode 100644 index 0000000..0e3e6ca --- /dev/null +++ b/templates/logrotate.conf.erb @@ -0,0 +1,35 @@ +/var/log/munin/munin-update.log { + daily + missingok + rotate 7 + compress + notifempty + create 640 munin adm +} + +/var/log/munin/munin-graph.log { + daily + missingok + rotate 7 + compress + notifempty + create 660 munin <%= @apache_user %> +} + +/var/log/munin/munin-html.log { + daily + missingok + rotate 7 + compress + notifempty + create 640 munin adm +} + +/var/log/munin/munin-limits.log { + daily + missingok + rotate 7 + compress + notifempty + create 640 munin adm +} -- cgit v1.2.3 From 151b37a22ee5822101aa316d0c0620ad535c80d1 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 23:09:29 +0200 Subject: Remove useless files --- files/config/host/munin.conf.header.Debian.sid | 75 ---------------------- files/config/host/munin.conf.header.Debian.squeeze | 75 ---------------------- files/config/host/munin.conf.header.Debian.wheezy | 75 ---------------------- files/empty/.ignore | 1 - files/modules_dir/.ignore | 0 5 files changed, 226 deletions(-) delete mode 100644 files/config/host/munin.conf.header.Debian.sid delete mode 100644 files/config/host/munin.conf.header.Debian.squeeze delete mode 100644 files/config/host/munin.conf.header.Debian.wheezy delete mode 100644 files/empty/.ignore delete mode 100644 files/modules_dir/.ignore diff --git a/files/config/host/munin.conf.header.Debian.sid b/files/config/host/munin.conf.header.Debian.sid deleted file mode 100644 index 771d50d..0000000 --- a/files/config/host/munin.conf.header.Debian.sid +++ /dev/null @@ -1,75 +0,0 @@ -# Example configuration file for Munin, generated by 'make build' - -# The next three variables specifies where the location of the RRD -# databases, the HTML output, and the logs, severally. They all -# must be writable by the user running munin-cron. -dbdir /var/lib/munin -htmldir /var/cache/munin/www -logdir /var/log/munin -rundir /var/run/munin - -# Where to look for the HTML templates -tmpldir /etc/munin/templates - -# Make graphs show values per minute instead of per second -#graph_period minute - -# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime -# something changes (OK -> WARNING, CRITICAL -> OK, etc) -#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm -#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm -# -# For those with Nagios, the following might come in handy. In addition, -# the services must be defined in the Nagios server as well. -#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg - -#contacts me -#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root -#contact.me.always_send warning critical - -# a simple host tree -#[localhost] -# address 127.0.0.1 -# use_node_name yes - -# -# A more complex example of a host tree -# -## First our "normal" host. -# [fii.foo.com] -# address foo -# -## Then our other host... -# [fay.foo.com] -# address fay -# -## Then we want totals... -# [foo.com;Totals] #Force it into the "foo.com"-domain... -# update no # Turn off data-fetching for this "host". -# -# # The graph "load1". We want to see the loads of both machines... -# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" -# load1.graph_title Loads side by side -# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# -# # The graph "load2". Now we want them stacked on top of each other. -# load2.graph_title Loads on top of each other -# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# load2.dummy_field.draw AREA # We want area instead the default LINE2. -# load2.dummy_field.label dummy # This is needed. Silly, really. -# -# # The graph "load3". Now we want them summarised into one field -# load3.graph_title Loads summarised -# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load -# load3.combined_loads.label Combined loads # Must be set, as this is -# # not a dummy field! -# -## ...and on a side note, I want them listen in another order (default is -## alphabetically) -# -# # Since [foo.com] would be interpreted as a host in the domain "com", we -# # specify that this is a domain by adding a semicolon. -# [foo.com;] -# node_order Totals fii.foo.com fay.foo.com -# - diff --git a/files/config/host/munin.conf.header.Debian.squeeze b/files/config/host/munin.conf.header.Debian.squeeze deleted file mode 100644 index 771d50d..0000000 --- a/files/config/host/munin.conf.header.Debian.squeeze +++ /dev/null @@ -1,75 +0,0 @@ -# Example configuration file for Munin, generated by 'make build' - -# The next three variables specifies where the location of the RRD -# databases, the HTML output, and the logs, severally. They all -# must be writable by the user running munin-cron. -dbdir /var/lib/munin -htmldir /var/cache/munin/www -logdir /var/log/munin -rundir /var/run/munin - -# Where to look for the HTML templates -tmpldir /etc/munin/templates - -# Make graphs show values per minute instead of per second -#graph_period minute - -# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime -# something changes (OK -> WARNING, CRITICAL -> OK, etc) -#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm -#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm -# -# For those with Nagios, the following might come in handy. In addition, -# the services must be defined in the Nagios server as well. -#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg - -#contacts me -#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root -#contact.me.always_send warning critical - -# a simple host tree -#[localhost] -# address 127.0.0.1 -# use_node_name yes - -# -# A more complex example of a host tree -# -## First our "normal" host. -# [fii.foo.com] -# address foo -# -## Then our other host... -# [fay.foo.com] -# address fay -# -## Then we want totals... -# [foo.com;Totals] #Force it into the "foo.com"-domain... -# update no # Turn off data-fetching for this "host". -# -# # The graph "load1". We want to see the loads of both machines... -# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" -# load1.graph_title Loads side by side -# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# -# # The graph "load2". Now we want them stacked on top of each other. -# load2.graph_title Loads on top of each other -# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# load2.dummy_field.draw AREA # We want area instead the default LINE2. -# load2.dummy_field.label dummy # This is needed. Silly, really. -# -# # The graph "load3". Now we want them summarised into one field -# load3.graph_title Loads summarised -# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load -# load3.combined_loads.label Combined loads # Must be set, as this is -# # not a dummy field! -# -## ...and on a side note, I want them listen in another order (default is -## alphabetically) -# -# # Since [foo.com] would be interpreted as a host in the domain "com", we -# # specify that this is a domain by adding a semicolon. -# [foo.com;] -# node_order Totals fii.foo.com fay.foo.com -# - diff --git a/files/config/host/munin.conf.header.Debian.wheezy b/files/config/host/munin.conf.header.Debian.wheezy deleted file mode 100644 index 771d50d..0000000 --- a/files/config/host/munin.conf.header.Debian.wheezy +++ /dev/null @@ -1,75 +0,0 @@ -# Example configuration file for Munin, generated by 'make build' - -# The next three variables specifies where the location of the RRD -# databases, the HTML output, and the logs, severally. They all -# must be writable by the user running munin-cron. -dbdir /var/lib/munin -htmldir /var/cache/munin/www -logdir /var/log/munin -rundir /var/run/munin - -# Where to look for the HTML templates -tmpldir /etc/munin/templates - -# Make graphs show values per minute instead of per second -#graph_period minute - -# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime -# something changes (OK -> WARNING, CRITICAL -> OK, etc) -#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm -#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm -# -# For those with Nagios, the following might come in handy. In addition, -# the services must be defined in the Nagios server as well. -#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg - -#contacts me -#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root -#contact.me.always_send warning critical - -# a simple host tree -#[localhost] -# address 127.0.0.1 -# use_node_name yes - -# -# A more complex example of a host tree -# -## First our "normal" host. -# [fii.foo.com] -# address foo -# -## Then our other host... -# [fay.foo.com] -# address fay -# -## Then we want totals... -# [foo.com;Totals] #Force it into the "foo.com"-domain... -# update no # Turn off data-fetching for this "host". -# -# # The graph "load1". We want to see the loads of both machines... -# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" -# load1.graph_title Loads side by side -# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# -# # The graph "load2". Now we want them stacked on top of each other. -# load2.graph_title Loads on top of each other -# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load -# load2.dummy_field.draw AREA # We want area instead the default LINE2. -# load2.dummy_field.label dummy # This is needed. Silly, really. -# -# # The graph "load3". Now we want them summarised into one field -# load3.graph_title Loads summarised -# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load -# load3.combined_loads.label Combined loads # Must be set, as this is -# # not a dummy field! -# -## ...and on a side note, I want them listen in another order (default is -## alphabetically) -# -# # Since [foo.com] would be interpreted as a host in the domain "com", we -# # specify that this is a domain by adding a semicolon. -# [foo.com;] -# node_order Totals fii.foo.com fay.foo.com -# - diff --git a/files/empty/.ignore b/files/empty/.ignore deleted file mode 100644 index 91162ec..0000000 --- a/files/empty/.ignore +++ /dev/null @@ -1 +0,0 @@ -# just used for git diff --git a/files/modules_dir/.ignore b/files/modules_dir/.ignore deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3