]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/apache/providers/module.rb
Modernise squid_fragment LWRP
[chef.git] / cookbooks / apache / providers / module.rb
index 17008371ec844d55698c49fcd2364f87432db2f6..d3f069b7fb77a4550a5ed18a2e51d73331a5f8b9 100644 (file)
@@ -21,75 +21,57 @@ def whyrun_supported?
   true
 end
 
-action :install do
-  if not installed?
-    package package_name
+use_inline_resources
 
-    updated = true
-  else
-    updated = false
-  end
+action :install do
+  package package_name unless installed?
 
-  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
+      mode 0o644
       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
-  if not enabled?
-    link enabled_name("load") do
-      to available_name("load")
-      owner "root"
-      group "root"
-      notifies :restart, "service[apache2]"
-    end
+  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("conf") do
-      to available_name("conf")
-      owner "root"
-      group "root"
-      notifies :reload, "service[apache2]"
-      only_if { ::File.exists?(available_name("conf")) }
-    end
+  link enabled_name("load") do
+    to available_name("load")
+    owner "root"
+    group "root"
+  end
 
-    new_resource.updated_by_last_action(true)
+  link enabled_name("conf") do
+    to available_name("conf")
+    owner "root"
+    group "root"
+    only_if { ::File.exist?(available_name("conf")) }
   end
 end
 
 action :disable do
-  if enabled?
-    link enabled_name("load") do
-      action :delete
-      notifies :restart, "service[apache2]"
-    end
-
-    link enabled_name("conf") do
-      action :delete
-      notifies :reload, "service[apache2]"
-    end
+  link enabled_name("load") do
+    action :delete
+  end
 
-    new_resource.updated_by_last_action(true)
+  link enabled_name("conf") do
+    action :delete
   end
 end
 
 action :delete do
-  if installed?
-    package package_name do
-      action :remove
-    end
-
-    new_resource.updated_by_last_action(true)
+  package package_name do
+    action :remove
   end
 end
 
@@ -106,9 +88,5 @@ def enabled_name(extension)
 end
 
 def installed?
-  ::File.exists?(available_name("load"))
-end
-
-def enabled?
-  ::File.exists?(enabled_name("load"))
+  ::File.exist?(available_name("load"))
 end