From 9b161f0c61bbd30960e663eceef8f1b35f633507 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 5 Nov 2011 14:14:32 +0100 Subject: use hiera to configure munin node specific things --- README | 32 ++++++++++++-------------------- manifests/client.pp | 7 ------- manifests/client/base.pp | 8 +++----- manifests/register.pp | 10 ++++------ manifests/register/snmp.pp | 5 +---- templates/munin-node.conf.Debian.etch | 8 ++++---- templates/munin-node.conf.default | 8 ++++---- 7 files changed, 28 insertions(+), 50 deletions(-) diff --git a/README b/README index b00e646..22bb19f 100644 --- a/README +++ b/README @@ -28,33 +28,25 @@ To use this module, follow these directions: a. Your modules directory will need all the files included in this repository placed under a directory called "munin" - b. add the following line to your modules.pp: - - import "munin" - - (NOTE: if you have followed the directions in README.common then you will have import - "modules.pp" in your site.pp, if you do not have that, then you will need to add the - import line to your site.pp) - - c. Add to the top of your site.pp a variable which indicates what IP should be allowed to + b. Add your hiera storage value for munin_allow which indicates what IP should be allowed to connect to your individual munin-nodes (this is typically your main munin host's IP): - $munin_allow = '192.168.0.1' + munin_allow: '192.168.0.1' - If you want to define more than one host, you can seperate them by colon: + If you want to define more than one host, you can define them as an array: - $munin_allow = '127.0.0.1:192.168.0.1' + munin_allow: ['127.0.0.1','192.168.0.1'] - d. In the node definition in your site.pp for your main munin host, add the following: + c. In the node definition in your site.pp for your main munin host, add the following: include munin::host - e. On each node that will gather munin statistics, add this line to that node's entry + d. On each node that will gather munin statistics, add this line to that node's entry in site.pp (you may want to also add this to your main munin host): include munin::client - f. If there are particular munin plugins you want to enable or configure, you define them + e. If there are particular munin plugins you want to enable or configure, you define them in the node definition, like follows: # Enable monitoring of disk stats in bytes @@ -74,13 +66,13 @@ To use this module, follow these directions: } - g. If you have Linux-Vservers configured, you will likely have multiple munin-node processes + f. If you have Linux-Vservers configured, you will likely have multiple munin-node processes competing for the default port 4949, for those nodes, set an alternate port for munin-node - to run on by putting something similar to the following in the node definition: + to run on by putting something similar to the following in hiera's node scope: - $munin_port = 4948 + munin_port: 4948 - h. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto + g. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto For CentOS this is enabled in the default header config - i. Per default (on CentOS) munin will send warnings and critical messages to root + h. Per default (on CentOS) munin will send warnings and critical messages to root diff --git a/manifests/client.pp b/manifests/client.pp index 141c916..99480f1 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -5,13 +5,6 @@ class munin::client { - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => '*', - 'fqdn' => '*', - default => $munin_host - } - case $operatingsystem { openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 17387e8..6b4bef9 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,4 +1,6 @@ -class munin::client::base { +class munin::client::base( + $munin_allow = hiera('munin_allow','127.0.0.1') +) { service { 'munin-node': ensure => running, enable => true, @@ -9,10 +11,6 @@ class munin::client::base { ensure => directory, mode => 0755, owner => root, group => 0; } - $real_munin_allow = $munin_allow ? { - '' => '127.0.0.1', - default => $munin_allow - } file {'/etc/munin/munin-node.conf': content => template("munin/munin-node.conf.$operatingsystem"), notify => Service['munin-node'], diff --git a/manifests/register.pp b/manifests/register.pp index 78d13d3..3c542ff 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -9,18 +9,16 @@ define munin::register ( $client_type = 'client' $munin_port_real = $port ? { - 'absent' => $munin_port ? { - '' => 4949, - default => $munin_port - }, + 'absent' => hiera('munin_port','4949'), default => $port } + $hiera_munin_host = hiera('munin_host','') $munin_host_real = $host ? { - 'absent' => $munin_host ? { + 'absent' => $hiera_munin_host ? { '' => $fqdn, 'fqdn' => $fqdn, - default => $munin_host + default => $hiera_munin_host }, default => $host } diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index c45adb0..a4d0d88 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -10,10 +10,7 @@ define munin::register::snmp ( $config = [ 'use_node_name no' ] $munin_port_real = $port ? { - 'absent' => $munin_port ? { - '' => 4949, - default => $munin_port - }, + 'absent' => hiera('munin_port','4949'), default => $port } diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch index 56da89d..17162d8 100644 --- a/templates/munin-node.conf.Debian.etch +++ b/templates/munin-node.conf.Debian.etch @@ -9,8 +9,8 @@ background 1 setseid 1 # Which host/port to bind to; -host <%= munin_host_real %> -port <%= munin_port_real %> +host <%= scope.function_hiera('munin_host','*') %> +port <%= scope.function_hiera('munin_port','4949') %> user root group root setsid yes @@ -33,7 +33,7 @@ host_name <%= fqdn %> # 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 -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index be62848..d67a9f8 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -37,8 +37,8 @@ host_name <%= fqdn %> # network notation unless the perl module Net::CIDR is installed. You # may repeat the allow line as many times as you'd like -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> # If you have installed the Net::CIDR perl module, you can use @@ -51,9 +51,9 @@ allow <%= '^'+val.gsub(/\./, '\.')+'$' %> # cidr_deny 192.0.2.42/32 # Which address to bind to; -host <%= munin_host_real %> +host <%= scope.function_hiera('munin_host','*') %> # host 127.0.0.1 # And which port -port <%= munin_port_real %> +port <%= scope.function_hiera('munin_port','4949') %> -- cgit v1.2.3