]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/providers/plugin.rb
add function to create and delete tablespaces
[chef.git] / cookbooks / munin / providers / plugin.rb
index c058524b91a4a9303a6bdbc4971cf51b23a44d0e..23b9753d87428d0ca87a9627c37cac907d2b3118 100644 (file)
@@ -21,50 +21,40 @@ def whyrun_supported?
   true
 end
 
+use_inline_resources
+
 action :create do
   link_action = case target_path
                 when nil then :delete
                 else :create
                 end
 
-  l = link plugin_path do
+  link plugin_path do
     action link_action
     to target_path
-    notifies :restart, "service[munin-node]"
   end
 
-  updated = l.updated_by_last_action?
-
-  if new_resource.conf
-    c = munin_plugin_conf new_resource.name do
+  if new_resource.conf # ~FC023
+    munin_plugin_conf new_resource.name do
       cookbook new_resource.conf_cookbook
       template new_resource.conf
       variables new_resource.conf_variables
+      restart_munin false
     end
-
-    updated = updated || c.updated_by_last_action?
   end
-
-  new_resource.updated_by_last_action(updated)
 end
 
 action :delete do
-  l = link plugin_path do
+  link plugin_path do
     action :delete
-    notifies :restart, "service[munin-node]"
   end
 
-  updated = l.updated_by_last_action?
-
-  if new_resource.conf
-    c = munin_plugin_conf new_resource.name do
+  if new_resource.conf # ~FC023
+    munin_plugin_conf new_resource.name do
       action :delete
+      restart_munin false
     end
-
-    updated = updated || c.updated_by_last_action?
   end
-
-  new_resource.updated_by_last_action(updated)
 end
 
 def plugin_path
@@ -72,15 +62,12 @@ def plugin_path
 end
 
 def target_path
-  case
-  when ::File.exist?(target)
+  if ::File.exist?(target)
     target
-  when ::File.exist?("/usr/local/share/munin/plugins/#{target}")
+  elsif ::File.exist?("/usr/local/share/munin/plugins/#{target}")
     "/usr/local/share/munin/plugins/#{target}"
-  when ::File.exist?("/usr/share/munin/plugins/#{target}")
+  elsif ::File.exist?("/usr/share/munin/plugins/#{target}")
     "/usr/share/munin/plugins/#{target}"
-  else
-    nil
   end
 end