]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apache/recipes/default.rb
Manage httpd.conf correctly for apache 2.4
[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 if node[:lsb][:release].to_f < 14.04
43   template "/etc/apache2/httpd.conf" do
44     source "httpd.conf.erb"
45     owner "root"
46     group "root"
47     mode 0644
48     notifies :reload, "service[apache2]"
49   end
50 else
51   apache_conf "httpd" do
52     template "httpd.conf.erb"
53     notifies :reload, "service[apache2]"
54   end
55 end
56
57 template "/etc/apache2/ports.conf" do
58   source "ports.conf.erb"
59   owner "root"
60   group "root"
61   mode 0644
62 end
63
64 service "apache2" do
65   action [ :enable, :start ]
66   supports :status => true, :restart => true, :reload => true
67 end
68
69 apache_module "info" do
70   conf "info.conf.erb"
71   variables :hosts => admins["hosts"]
72 end
73
74 apache_module "status" do
75   conf "status.conf.erb"
76   variables :hosts => admins["hosts"]
77 end
78
79 apache_module "reqtimeout" do
80   action [ :disable ]
81 end
82
83 munin_plugin "apache_accesses"
84 munin_plugin "apache_processes"
85 munin_plugin "apache_volume"