2 # Cookbook Name:: apache
3 # Resource:: 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 # https://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.
20 default_action [:install, :enable]
22 property :module, :kind_of => String, :name_attribute => true
23 property :package, :kind_of => String
24 property :conf, :kind_of => String
25 property :variables, :kind_of => Hash, :default => {}
26 property :restart_apache, :kind_of => [TrueClass, FalseClass], :default => true
29 declare_resource :package, package_name unless installed?
31 if new_resource.conf # ~FC023
32 template available_name("conf") do
33 source new_resource.conf
37 variables new_resource.variables
43 execute "a2enmod-#{new_resource.module}" do
44 command "a2enmod #{new_resource.module}"
47 not_if { ::File.exist?(enabled_name("load")) }
50 link enabled_name("load") do
51 to available_name("load")
56 link enabled_name("conf") do
57 to available_name("conf")
60 only_if { ::File.exist?(available_name("conf")) }
65 link enabled_name("load") do
69 link enabled_name("conf") do
75 package package_name do
82 new_resource.package || "libapache2-mod-#{new_resource.module}"
85 def available_name(extension)
86 "/etc/apache2/mods-available/#{new_resource.module}.#{extension}"
89 def enabled_name(extension)
90 "/etc/apache2/mods-enabled/#{new_resource.module}.#{extension}"
94 ::File.exist?(available_name("load"))
99 notifies :restart, "service[apache2]" if restart_apache