2 # Cookbook Name:: apache
3 # Provider:: apache_module
5 # Copyright 2013, OpenStreetMap Foundation
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
34 t = template available_name("conf") do
35 source new_resource.conf
39 variables new_resource.variables
40 notifies :reload, "service[apache2]" if enabled?
43 updated = updated || t.updated_by_last_action?
46 new_resource.updated_by_last_action(updated)
51 link enabled_name("load") do
52 to available_name("load")
55 notifies :restart, "service[apache2]"
58 link enabled_name("conf") do
59 to available_name("conf")
62 notifies :reload, "service[apache2]"
63 only_if { ::File.exist?(available_name("conf")) }
66 new_resource.updated_by_last_action(true)
72 link enabled_name("load") do
74 notifies :restart, "service[apache2]"
77 link enabled_name("conf") do
79 notifies :reload, "service[apache2]"
82 new_resource.updated_by_last_action(true)
88 package package_name do
92 new_resource.updated_by_last_action(true)
97 new_resource.package || "libapache2-mod-#{new_resource.name}"
100 def available_name(extension)
101 "/etc/apache2/mods-available/#{new_resource.name}.#{extension}"
104 def enabled_name(extension)
105 "/etc/apache2/mods-enabled/#{new_resource.name}.#{extension}"
109 ::File.exist?(available_name("load"))
113 ::File.exist?(enabled_name("load"))