]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/apache/providers/module.rb
User a2enmod so dependencies get enabled
[chef.git] / cookbooks / apache / providers / module.rb
index 29ef1621c4fa238fa17f158120c43e30aa181c0d..c5efdd2c58d938101443b85f17cafb0f3511d35b 100644 (file)
@@ -21,69 +21,60 @@ def whyrun_supported?
   true
 end
 
+use_inline_resources
+
 action :install do
-  p = package package_name do
-    action :install
-    not_if { ::File.exists?(available_name("load")) }
+  unless installed?
+    package package_name
   end
 
-  updated = p.updated_by_last_action?
-
-  if new_resource.conf
-    t = template available_name("conf") do
+  if new_resource.conf # ~FC023
+    template available_name("conf") do
       source new_resource.conf
       owner "root"
       group "root"
       mode 0644
       variables new_resource.variables
-      notifies :reload, "service[apache2]" if enabled?
     end
-
-    updated = updated || t.updated_by_last_action?
   end
-
-  new_resource.updated_by_last_action(updated)
 end
 
 action :enable do
-  l = link enabled_name("load") do
+  execute "a2enmod-#{new_resource.name}" do
+    command "a2enmod #{new_resource.name}"
+    user "root"
+    group "root"
+    not_if { ::File.exist?(enabled_name("load")) }
+  end
+
+  link enabled_name("load") do
     to available_name("load")
     owner "root"
     group "root"
-    notifies :restart, "service[apache2]"
   end
 
-  c = link enabled_name("conf") do
+  link enabled_name("conf") do
     to available_name("conf")
     owner "root"
     group "root"
-    notifies :reload, "service[apache2]"
-    only_if { ::File.exists?(available_name("conf")) }
+    only_if { ::File.exist?(available_name("conf")) }
   end
-
-  new_resource.updated_by_last_action(l.updated_by_last_action? || c.updated_by_last_action?)
 end
 
 action :disable do
-  l = link enabled_name("load") do
+  link enabled_name("load") do
     action :delete
-    notifies :restart, "service[apache2]"
   end
 
-  c = link enabled_name("conf") do
+  link enabled_name("conf") do
     action :delete
-    notifies :reload, "service[apache2]"
   end
-
-  new_resource.updated_by_last_action(l.updated_by_last_action? || c.updated_by_last_action?)
 end
 
 action :delete do
-  p = package package_name do
+  package package_name do
     action :remove
   end
-
-  new_resource.updated_by_last_action(p.updated_by_last_action?)
 end
 
 def package_name
@@ -98,6 +89,6 @@ def enabled_name(extension)
   "/etc/apache2/mods-enabled/#{new_resource.name}.#{extension}"
 end
 
-def enabled?
-  ::File.exists?(enabled_name("load"))
+def installed?
+  ::File.exist?(available_name("load"))
 end