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.
25 p = package package_name do
27 not_if { ::File.exists?(available_name("load")) }
30 updated = p.updated_by_last_action?
33 t = template available_name("conf") do
34 source new_resource.conf
38 variables new_resource.variables
39 notifies :reload, "service[apache2]" if enabled?
42 updated = updated || t.updated_by_last_action?
45 new_resource.updated_by_last_action(updated)
49 l = link enabled_name("load") do
50 to available_name("load")
53 notifies :restart, "service[apache2]"
56 c = link enabled_name("conf") do
57 to available_name("conf")
60 notifies :reload, "service[apache2]"
61 only_if { ::File.exists?(available_name("conf")) }
64 new_resource.updated_by_last_action(l.updated_by_last_action? || c.updated_by_last_action?)
68 l = link enabled_name("load") do
70 notifies :restart, "service[apache2]"
73 c = link enabled_name("conf") do
75 notifies :reload, "service[apache2]"
78 new_resource.updated_by_last_action(l.updated_by_last_action? || c.updated_by_last_action?)
82 p = package package_name do
86 new_resource.updated_by_last_action(p.updated_by_last_action?)
90 new_resource.package || "libapache2-mod-#{new_resource.name}"
93 def available_name(extension)
94 "/etc/apache2/mods-available/#{new_resource.name}.#{extension}"
97 def enabled_name(extension)
98 "/etc/apache2/mods-enabled/#{new_resource.name}.#{extension}"
102 ::File.exists?(enabled_name("load"))