]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apache/recipes/default.rb
59d45d09d696369f9463c8bb1523a7e3ea1b7667
[chef.git] / cookbooks / apache / recipes / default.rb
1 #
2 # Cookbook:: 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 #     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 "munin"
21 include_recipe "ssl"
22
23 package %w[
24   apache2
25   libwww-perl
26 ]
27
28 %w[event itk prefork worker].each do |mpm|
29   next if mpm == node[:apache][:mpm]
30
31   apache_module "mpm_#{mpm}" do
32     action [:disable]
33   end
34 end
35
36 apache_module "mpm_#{node[:apache][:mpm]}" do
37   action [:enable]
38 end
39
40 apache_module "http2"
41
42 admins = data_bag_item("apache", "admins")
43
44 apache_conf "httpd" do
45   template "httpd.conf.erb"
46   notifies :reload, "service[apache2]"
47 end
48
49 template "/etc/apache2/ports.conf" do
50   source "ports.conf.erb"
51   owner "root"
52   group "root"
53   mode 0o644
54 end
55
56 service "apache2" do
57   action [:enable, :start]
58   retries 2
59   retry_delay 10
60   supports :status => true, :restart => true, :reload => true
61 end
62
63 apache_module "info" do
64   conf "info.conf.erb"
65   variables :hosts => admins["hosts"]
66 end
67
68 apache_module "status" do
69   conf "status.conf.erb"
70   variables :hosts => admins["hosts"]
71 end
72
73 apache_module "deflate" do
74   conf "deflate.conf.erb"
75 end
76
77 if node[:apache][:reqtimeout]
78   apache_module "reqtimeout" do
79     action [:enable]
80   end
81 else
82   apache_module "reqtimeout" do
83     action [:disable]
84   end
85 end
86
87 apache_module "headers"
88 apache_module "ssl"
89
90 apache_conf "ssl" do
91   template "ssl.erb"
92 end
93
94 munin_plugin "apache_accesses"
95 munin_plugin "apache_processes"
96 munin_plugin "apache_volume"