]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/recipes/server.rb
Fix rubocop warnings
[chef.git] / cookbooks / munin / recipes / server.rb
1 #
2 # Cookbook Name:: munin
3 # Recipe:: server
4 #
5 # Copyright 2010, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "apache"
21
22 package "munin"
23 package "rrdcached"
24 package "libcgi-fast-perl"
25
26 template "/etc/default/rrdcached" do
27   source "rrdcached.erb"
28   owner "root"
29   group "root"
30   mode 0644
31 end
32
33 directory "/var/lib/munin/rrdcached" do
34   owner "munin"
35   group "munin"
36   mode 0755
37 end
38
39 service "rrdcached" do
40   action [:enable, :start]
41   subscribes :restart, "template[/etc/default/rrdcached]"
42 end
43
44 munin_plugin "rrdcached"
45
46 expiry_time = 14 * 86400
47
48 clients = search(:node, "recipes:munin").select { |n| n[:munin] }.sort_by { |n| n[:hostname] }
49 frontends = search(:node, "recipes:web\\:\\:frontend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.map { |n| n[:hostname] }.sort
50 backends = search(:node, "recipes:web\\:\\:backend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.map { |n| n[:hostname] }.sort
51 tilecaches = search(:node, "roles:tilecache").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by { |n| n[:hostname] }.map do |n|
52   { :name => n[:hostname], :interface => n.interfaces(:role => :external).first[:interface] }
53 end
54 renderers = search(:node, "roles:tile").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by { |n| n[:hostname] }.map do |n|
55   { :name => n[:hostname], :interface => n.interfaces(:role => :external).first[:interface] }
56 end
57
58 template "/etc/munin/munin.conf" do
59   source "munin.conf.erb"
60   owner "root"
61   group "root"
62   mode 0644
63   variables :expiry_time => expiry_time, :clients => clients, :frontends => frontends, :backends => backends, :tilecaches => tilecaches, :renderers => renderers
64 end
65
66 apache_module "fcgid"
67 apache_module "rewrite"
68
69 remote_directory "/srv/munin.openstreetmap.org" do
70   source "www"
71   owner "root"
72   group "root"
73   mode 0755
74   files_owner "root"
75   files_group "root"
76   files_mode 0755
77   purge true
78 end
79
80 apache_site "munin.openstreetmap.org" do
81   template "apache.erb"
82 end
83
84 munin_plugin "munin_stats"
85 munin_plugin "munin_update"
86 munin_plugin "munin_rrdcached"