From c95f0b2fcf4f35b1a7ae3ad9c04600a32ab2bb43 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 13 Jun 2012 20:40:57 -0300 Subject: migrate away from hiera stuff --- README | 6 +++--- manifests/client.pp | 16 +++++++++++----- manifests/client/base.pp | 6 +++--- manifests/host.pp | 2 +- manifests/register.pp | 19 ++----------------- manifests/register/snmp.pp | 9 ++------- templates/client.erb | 8 ++++---- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/README b/README index 22bb19f..1e47d27 100644 --- a/README +++ b/README @@ -28,7 +28,7 @@ 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 your hiera storage value for munin_allow which indicates what IP should be allowed to + b. Add your class parameter for munin::client::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' @@ -68,9 +68,9 @@ To use this module, follow these directions: 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 hiera's node scope: + to run on by putting something similar to the following class parameter: - munin_port: 4948 + port => 4948 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 diff --git a/manifests/client.pp b/manifests/client.pp index 79d275e..934d23a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -4,9 +4,11 @@ # Adapted and improved by admin(at)immerda.ch class munin::client( - $allow = hiera('munin_client_allow',['127.0.0.1']), - $host = hiera('munin_host','*'), - $port = hiera('munin_port','4949') + $allow = [ '127.0.0.1' ], + $host = '*', + $port = '4949', + $manage_shorewall = false, + $shorewall_collector_source = 'net' ) { case $::operatingsystem { openbsd: { include munin::client::openbsd } @@ -16,7 +18,11 @@ class munin::client( centos: { include munin::client::package } default: { include munin::client::base } } - if hiera('use_shorewall',false) { - include shorewall::rules::munin + if $munin::client::manage_shorewall { + class{'shorewall::rules::munin': + munin_port => $port, + munin_collector => delete($allow,'127.0.0.1'), + collector_source => $shorewall_collector_source, + } } } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 80a25c5..1cba47b 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,6 +1,4 @@ -class munin::client::base( - $munin_allow = hiera('munin_allow','127.0.0.1') -) { +class munin::client::base { service { 'munin-node': ensure => running, enable => true, @@ -17,6 +15,8 @@ class munin::client::base( mode => 0644, owner => root, group => 0, } munin::register { $::fqdn: + host => $munin::client::host, + port => $munin::client::port, config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], } include munin::plugins::base diff --git a/manifests/host.pp b/manifests/host.pp index 524cddf..b828e35 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -37,7 +37,7 @@ class munin::host( content => "4,34 * * * * root if $(ps ax | grep -v grep | grep -q munin-run); then killall munin-run; fi\n", owner => root, group => 0, mode => 0644; } - if hiera('use_shorewall',false) { + if $munin::host::manage_shorewall { include shorewall::rules::out::munin } } diff --git a/manifests/register.pp b/manifests/register.pp index 14019d0..2645542 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -1,6 +1,6 @@ define munin::register ( - $host = 'absent', - $port = 'absent', + $host = $::fqdn, + $port = '4949', $description = 'absent', $config = [] ) @@ -8,21 +8,6 @@ define munin::register ( $fhost = $name $client_type = 'client' - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } - - $hiera_munin_host = hiera('munin_host','') - $munin_host_real = $host ? { - 'absent' => $hiera_munin_host ? { - '' => $::fqdn, - 'fqdn' => $::fqdn, - default => $hiera_munin_host - }, - default => $host - } - @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": target => '/etc/munin/munin.conf', content => template("munin/client.erb"), diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index 3007b67..78c3e91 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -1,18 +1,13 @@ define munin::register::snmp ( $community = 'public', $description = 'absent', - $port = 'absent' + $port = '4949', + $host = $::fqdn ) { $fhost = $name - $munin_host_real = $::fqdn $client_type = 'snmp' $config = [ 'use_node_name no' ] - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } - exec { "munin_register_snmp_${fhost}": command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", diff --git a/templates/client.erb b/templates/client.erb index 8c93cc5..7131ade 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -1,19 +1,19 @@ <% # Downcase all information dom = scope.lookupvar('::domain').downcase - host = scope.lookupvar('::hostname').downcase + h = scope.lookupvar('::hostname').downcase %> ### Munin client from Puppet template # Domain: <%= dom %> -# Registered on: <%= host %> +# Registered on: <%= h %> # Type: <%= client_type %> <% if description != 'absent' -%> # Description: <%= description.gsub!(/\n/, ' ') %> <% end -%> [<%= fhost.downcase %>] - address <%= munin_host_real %> - port <%= munin_port_real %> + address <%= host %> + port <%= port %> <% if config -%><% config.each do |val| -%> <%= val -%> <% end -%><% end -%> -- cgit v1.2.3