Skip to content
Browse files

COOK-920: FreeBSD support in the munin cookbook.

  • Loading branch information...
1 parent 4b24c31 commit 366441f8712516c036818de1021db45c2b32bcea @andreacampi andreacampi committed with jtimberman Dec 18, 2011
View
21 munin/attributes/default.rb
@@ -23,9 +23,30 @@
case node[:platform]
when "arch"
+ default['munin']['basedir'] = "/etc/munin"
+ default['munin']['plugin_dir'] = "/usr/share/munin/plugins"
default['munin']['docroot'] = "/srv/http/munin"
+ default['munin']['dbdir'] = "/var/lib/munin"
+ default['munin']['root']['group'] = "root"
when "centos","redhat"
+ default['munin']['basedir'] = "/etc/munin"
+ default['munin']['plugin_dir'] = "/usr/share/munin/plugins"
default['munin']['docroot'] = "/var/www/html/munin"
+ default['munin']['dbdir'] = "/var/lib/munin"
+ default['munin']['root']['group'] = "root"
+when "freebsd"
+ default['munin']['basedir'] = "/usr/local/etc/munin"
+ default['munin']['plugin_dir'] = "/usr/local/share/munin/plugins"
+ default['munin']['docroot'] = "/usr/local/www/munin"
+ default['munin']['dbdir'] = "/usr/local/var/munin"
+ default['munin']['root']['group'] = "wheel"
else
+ default['munin']['basedir'] = "/etc/munin"
+ default['munin']['plugin_dir'] = "/usr/share/munin/plugins"
default['munin']['docroot'] = "/var/www/munin"
+ default['munin']['dbdir'] = "/var/lib/munin"
+ default['munin']['root']['group'] = "root"
end
+
+default['munin']['plugins'] = "#{default['munin']['basedir']}/plugins"
+default['munin']['tmpldir'] = "#{default['munin']['basedir']}/templates"
View
12 munin/definitions/munin_plugin.rb
@@ -18,24 +18,26 @@
#
-define :munin_plugin, :plugin_config => "/etc/munin/plugins", :plugin_dir => "/usr/share/munin/plugins", :create_file => false, :enable => true do
+define :munin_plugin, :create_file => false, :enable => true do
include_recipe "munin::client"
plugin = params[:plugin] ? params[:plugin] : params[:name]
+ plugin_config = params[:plugin_config] ? params[:plugin_config] : node['munin']['plugins']
+ plugin_dir = params[:plugin_dir] ? params[:plugin_dir] : node['munin']['plugin_dir']
if params[:create_file]
- cookbook_file "#{params[:plugin_dir]}/#{params[:name]}" do
+ cookbook_file "#{plugin_dir}/#{params[:name]}" do
cookbook "munin"
source "plugins/#{params[:name]}"
owner "root"
- group "root"
+ group node['munin']['root']['group']
mode 0755
end
end
- link "#{params[:plugin_config]}/#{plugin}" do
- to "#{params[:plugin_dir]}/#{params[:name]}"
+ link "#{plugin_config}/#{plugin}" do
+ to "#{plugin_dir}/#{params[:name]}"
if params[:enable]
action :create
else
View
2 munin/metadata.rb
@@ -7,7 +7,7 @@
depends "apache2", ">= 1.0.6"
-%w{arch debian ubuntu redhat centos scientific fedora}.each do |os|
+%w{arch debian ubuntu redhat centos scientific fedora freebsd}.each do |os|
supports os
end
View
4 munin/recipes/client.rb
@@ -26,7 +26,7 @@
action :enable
end
-template "/etc/munin/munin-node.conf" do
+template "#{node['munin']['basedir']}/munin-node.conf" do
source "munin-node.conf.erb"
mode 0644
variables :munin_servers => munin_servers
@@ -36,7 +36,7 @@
case node[:platform]
when "arch"
execute "munin-node-configure --shell | sh" do
- not_if { Dir.entries("/etc/munin/plugins").length > 2 }
+ not_if { Dir.entries(node['munin']['plugins']).length > 2 }
notifies :restart, "service[munin-node]"
end
end
View
20 munin/recipes/server.rb
@@ -43,7 +43,12 @@
public_domain = node[:domain]
end
-package "munin"
+case node[:platform]
+when "freebsd"
+ package "munin-master"
+else
+ package "munin"
+end
case node[:platform]
when "arch"
@@ -52,17 +57,24 @@
user "munin"
minute "*/5"
end
+when "freebsd"
+ cron "munin-graph-html" do
+ command "/usr/local/bin/munin-cron"
+ user "munin"
+ minute "*/5"
+ ignore_failure true
+ end
else
cookbook_file "/etc/cron.d/munin" do
source "munin-cron"
mode "0644"
owner "root"
- group "root"
+ group node['munin']['root']['group']
backup 0
end
end
-template "/etc/munin/munin.conf" do
+template "#{node['munin']['basedir']}/munin.conf" do
source "munin.conf.erb"
mode 0644
variables(:munin_nodes => munin_servers, :docroot => node['munin']['docroot'])
@@ -72,7 +84,7 @@
when "openid"
include_recipe "apache2::mod_auth_openid"
else
- template "/etc/munin/htpasswd.users" do
+ template "#{node['munin']['basedir']}/htpasswd.users" do
source "htpasswd.users.erb"
owner "munin"
group node['apache']['group']
View
2 munin/templates/default/apache2.conf.erb
@@ -19,7 +19,7 @@
<Location />
AuthName "Munin Server"
AuthType Basic
- AuthUserFile "/etc/munin/htpasswd.users"
+ AuthUserFile "<%= node['munin']['basedir'] %>/htpasswd.users"
require valid-user
</Location>
<% end -%>
View
2 munin/templates/default/munin-node.conf.erb
@@ -12,7 +12,7 @@ setseid 1
# Which port to bind to;
host *
user root
-group root
+group <%= node['munin']['root']['group'] %>
setsid yes
# Regexps for files to ignore
View
4 munin/templates/default/munin.conf.erb
@@ -1,13 +1,13 @@
# 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
+dbdir <%= node['munin']['dbdir'] %>
htmldir <%= @docroot %>
logdir /var/log/munin
rundir /var/run/munin
# Where to look for the HTML templates
-tmpldir /etc/munin/templates
+tmpldir <%= node['munin']['tmpldir'] %>
# a simple host tree
<% @munin_nodes.each do |system| -%>

0 comments on commit 366441f

Please sign in to comment.
Something went wrong with that request. Please try again.