]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/recipes/server.rb
Add a load more cookbooks
[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
24 expiry_time = 14 * 86400
25
26 clients = search(:node, "recipes:munin").select { |n| n[:munin] }.sort_by { |n| n[:hostname] }
27 frontends = search(:node, "recipes:web\\:\\:frontend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.map { |n| n[:hostname] }.sort
28 backends = search(:node, "recipes:web\\:\\:backend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.map { |n| n[:hostname] }.sort
29 tilecaches = search(:node, "roles:tilecache").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by { |n| n[:hostname] }.map do |n|
30   { :name => n[:hostname], :interface => n.interfaces(:role => :external).first[:interface] }
31 end
32
33 template "/etc/munin/munin.conf" do
34   source "munin.conf.erb"
35   owner "root"
36   group "root"
37   mode 0644
38   variables :expiry_time => expiry_time, :clients => clients, :frontends => frontends, :backends => backends, :tilecaches => tilecaches
39 end
40
41 apache_site "munin.openstreetmap.org" do
42   template "apache.erb"
43 end
44
45 munin_plugin "munin_stats"
46 munin_plugin "munin_update"