diff --git a/templates/munin-node.conf.erb b/templates/munin-node.conf.erb index b187c59..d059b38 100644 --- a/templates/munin-node.conf.erb +++ b/templates/munin-node.conf.erb @@ -1,71 +1,77 @@ # /etc/munin/munin-node.conf - config-file for munin-node # # This file is handled by puppet, any local changes will be lost # <% require 'ipaddr' addresses = [] unrecognized = [] + rescuable_exceptions = [ ArgumentError ] + + if defined?(IPAddr::InvalidAddressError) + rescuable_exceptions << IPAddr::InvalidAddressError + end + Array(@allow).flatten.each do |line| begin a = IPAddr.new(line) if a.ipv4? or a.ipv6? addresses << line end - rescue ArgumentError, IPAddr::InvalidAddressError + rescue *rescuable_exceptions # Treat invalid addresses as "allow" arguments, as they can be # regular expressions. unrecognized << line end end -%> host_name <%= @host_name %> log_level 4 log_file <%= @_log_file %> <% if @log_destination == 'syslog' -%> <% if @syslog_facility -%> syslog_facility <%= @syslog_facility %> <% end -%> <% end -%> pid_file /var/run/munin/munin-node.pid background 1 setsid 1 # Which port and address to bind to; host <%= @bind_address %> port <%= @bind_port %> user root group <%= @file_group %> # Regexps for files to ignore ignore_file ~$ ignore_file \.bak$ ignore_file %$ ignore_file \.dpkg-(tmp|new|old|dist)$ ignore_file \.rpm(save|new)$ ignore_file \.puppet-bak$ # Hosts to allow <% addresses.each do |line| -%> <% if line.match(/\//) -%> cidr_allow <%= line %> <% else -%> allow ^<%= Regexp.quote(line) %>$ <% end -%> <% end -%> <% unrecognized.each do |line| -%> allow <%= line %> <% end -%> <% if @timeout -%> timeout <%= @timeout %> <% end -%> <% Array(@nodeconfig).each do |line| -%> <%= line %> <% end -%>