]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/recipes/server.rb
Merge remote-tracking branch 'github/pull/528'
[chef.git] / cookbooks / munin / recipes / server.rb
1 #
2 # Cookbook:: 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 #     https://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 "644"
31 end
32
33 directory "/var/lib/munin/rrdcached" do
34   owner "munin"
35   group "munin"
36   mode "755"
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\\:\\:default").sort_by(&:name)
49 frontends = search(:node, "recipes:web\\:\\:frontend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
50   { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
51 end
52 renderers = search(:node, "roles:tile").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
53   { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
54 end
55 geocoders = search(:node, "roles:nominatim").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
56   { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
57 end
58
59 template "/etc/munin/munin.conf" do
60   source "munin.conf.erb"
61   owner "root"
62   group "root"
63   mode "644"
64   variables :expiry_time => expiry_time, :clients => clients,
65             :frontends => frontends, :geocoders => geocoders,
66             :renderers => renderers
67 end
68
69 apache_module "fcgid"
70 apache_module "rewrite"
71 apache_module "headers"
72
73 remote_directory "/srv/munin.openstreetmap.org" do
74   source "www"
75   owner "root"
76   group "root"
77   mode "755"
78   files_owner "root"
79   files_group "root"
80   files_mode "644"
81 end
82
83 # directory to put dumped files in
84 directory "/srv/munin.openstreetmap.org/dumps" do
85   owner "www-data"
86   group "www-data"
87   mode "755"
88 end
89
90 ssl_certificate "munin.openstreetmap.org" do
91   domains ["munin.openstreetmap.org", "munin.osm.org"]
92   notifies :reload, "service[apache2]"
93 end
94
95 apache_site "munin.openstreetmap.org" do
96   template "apache.erb"
97 end
98
99 template "/etc/cron.daily/munin-backup" do
100   source "backup.cron.erb"
101   owner "root"
102   group "root"
103   mode "755"
104 end
105
106 munin_plugin "munin_stats"
107 munin_plugin "munin_update"
108 munin_plugin "munin_rrdcached"