]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apache/providers/module.rb
mediawiki: ignore tar file-changed warning
[chef.git] / cookbooks / apache / providers / module.rb
1 #
2 # Cookbook Name:: apache
3 # Provider:: apache_module
4 #
5 # Copyright 2013, 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 def whyrun_supported?
21   true
22 end
23
24 use_inline_resources
25
26 action :install do
27   package package_name unless installed?
28
29   if new_resource.conf # ~FC023
30     template available_name("conf") do
31       source new_resource.conf
32       owner "root"
33       group "root"
34       mode 0o644
35       variables new_resource.variables
36     end
37   end
38 end
39
40 action :enable do
41   execute "a2enmod-#{new_resource.name}" do
42     command "a2enmod #{new_resource.name}"
43     user "root"
44     group "root"
45     not_if { ::File.exist?(enabled_name("load")) }
46   end
47
48   link enabled_name("load") do
49     to available_name("load")
50     owner "root"
51     group "root"
52   end
53
54   link enabled_name("conf") do
55     to available_name("conf")
56     owner "root"
57     group "root"
58     only_if { ::File.exist?(available_name("conf")) }
59   end
60 end
61
62 action :disable do
63   link enabled_name("load") do
64     action :delete
65   end
66
67   link enabled_name("conf") do
68     action :delete
69   end
70 end
71
72 action :delete do
73   package package_name do
74     action :remove
75   end
76 end
77
78 def package_name
79   new_resource.package || "libapache2-mod-#{new_resource.name}"
80 end
81
82 def available_name(extension)
83   "/etc/apache2/mods-available/#{new_resource.name}.#{extension}"
84 end
85
86 def enabled_name(extension)
87   "/etc/apache2/mods-enabled/#{new_resource.name}.#{extension}"
88 end
89
90 def installed?
91   ::File.exist?(available_name("load"))
92 end