From c8be8b86afa5b13d0f090d8781a276e243c515c5 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Fri, 14 Jun 2013 01:52:27 +0300 Subject: [PATCH] Handle munin_allow and nagios_allow variables as arrays --- munin/manifests/init.pp | 7 +++++++ munin/templates/munin-node.conf.erb | 5 +++-- nagios/manifests/target.pp | 9 +++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/munin/manifests/init.pp b/munin/manifests/init.pp index 9442d76..a0515c1 100644 --- a/munin/manifests/init.pp +++ b/munin/manifests/init.pp @@ -3,11 +3,18 @@ # # === Global variables # +# $munin_allow: +# Array of IP addresses allowed to connect to munin-node. +# # $munin_tls: # Enable and require TLS if set to "true". # class munin::node { + if !$munin_allow { + $munin_allow = [ "127.0.0.1" ] + } + package { "munin-node": ensure => installed, } diff --git a/munin/templates/munin-node.conf.erb b/munin/templates/munin-node.conf.erb index e757c52..f145092 100644 --- a/munin/templates/munin-node.conf.erb +++ b/munin/templates/munin-node.conf.erb @@ -37,8 +37,9 @@ host_name <%= @homename %> # 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 - -allow <%= @munin_allow %> +<% @munin_allow.each do |allow| -%> +allow <%= "^%s$" % allow.gsub('.', '\.') %> +<% end -%> # Which address to bind to; host <%= @ipaddress %> diff --git a/nagios/manifests/target.pp b/nagios/manifests/target.pp index 354497e..a83410f 100644 --- a/nagios/manifests/target.pp +++ b/nagios/manifests/target.pp @@ -179,10 +179,15 @@ define nagios::target::tcp($port, $description=undef) { # Configure nagios nrpe target. # +# === Global variables +# +# $nagios_allow: +# Array of IP addresses allowed to connect to the nrpe service. +# class nagios::target::nrpe inherits nagios::target { if !$nagios_allow { - $nagios_allow = "127.0.0.1" + $nagios_allow = [ "127.0.0.1" ] } include nagios::common @@ -248,7 +253,7 @@ class nagios::target::nrpe inherits nagios::target { "openbsd" => "wheel", default => "root", }, - content => "allowed_hosts=${nagios_allow}\n", + content => inline_template("allowed_hosts=<%= @nagios_allow.join(',') %>\n"), require => File["/etc/nrpe.d"], notify => Service["nrpe"], }