]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apache/recipes/default.rb
23206572a37ecc3089bf7acf0baa4c3314180f82
[chef.git] / cookbooks / apache / recipes / default.rb
1 #
2 # Cookbook Name:: apache
3 # Recipe:: default
4 #
5 # Copyright 2011, 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 package "apache2"
21
22 if node[:lsb][:release].to_f < 14.04
23   package "apache2-mpm-#{node[:apache][:mpm]}" do
24     notifies :restart, "service[apache2]"
25   end
26 else
27   ["event", "itk", "prefork", "worker"].each do |mpm|
28     if mpm == node[:apache][:mpm]
29       apache_module "mpm_#{mpm}" do
30         action [ :enable ]
31       end
32     else
33       apache_module "mpm_#{mpm}" do
34         action [ :disable ]
35       end
36     end
37   end
38 end
39
40 admins = data_bag_item("apache", "admins")
41
42 template "/etc/apache2/httpd.conf" do
43   source "httpd.conf.erb"
44   owner "root"
45   group "root"
46   mode 0644
47 end
48
49 template "/etc/apache2/ports.conf" do
50   source "ports.conf.erb"
51   owner "root"
52   group "root"
53   mode 0644
54 end
55
56 service "apache2" do
57   action [ :enable, :start ]
58   supports :status => true, :restart => true, :reload => true
59   subscribes :reload, "template[/etc/apache2/httpd.conf]"
60 end
61
62 apache_module "info" do
63   conf "info.conf.erb"
64   variables :hosts => admins["hosts"]
65 end
66
67 apache_module "status" do
68   conf "status.conf.erb"
69   variables :hosts => admins["hosts"]
70 end
71
72 apache_module "reqtimeout" do
73   action [ :disable ]
74 end
75
76 munin_plugin "apache_accesses"
77 munin_plugin "apache_processes"
78 munin_plugin "apache_volume"