]> git.openstreetmap.org Git - chef.git/commitdiff
Clean up notification handling for the munin LWRPs
authorTom Hughes <tom@compton.nu>
Tue, 10 Feb 2015 10:18:34 +0000 (10:18 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 10 Feb 2015 10:21:41 +0000 (10:21 +0000)
cookbooks/munin/providers/plugin.rb
cookbooks/munin/resources/plugin.rb
cookbooks/munin/resources/plugin_conf.rb

index e469acb6d1610a70e4d8c7d3a74f9189c666b1fa..bcbb07746f85572e4639730950f8ed838754d5f3 100644 (file)
@@ -39,6 +39,7 @@ action :create do
       cookbook new_resource.conf_cookbook
       template new_resource.conf
       variables new_resource.conf_variables
       cookbook new_resource.conf_cookbook
       template new_resource.conf
       variables new_resource.conf_variables
+      restart_munin false
     end
   end
 end
     end
   end
 end
@@ -51,6 +52,7 @@ action :delete do
   if new_resource.conf # ~FC023
     munin_plugin_conf new_resource.name do
       action :delete
   if new_resource.conf # ~FC023
     munin_plugin_conf new_resource.name do
       action :delete
+      restart_munin false
     end
   end
 end
     end
   end
 end
index 5d36e13a5ac94b14d2c2cc86e3517789b8cd7d1b..d8861fafefdda145195f5d375a0a8460baf94009 100644 (file)
@@ -25,8 +25,8 @@ attribute :target, :kind_of => String
 attribute :conf, :kind_of => String
 attribute :conf_cookbook, :kind_of => String
 attribute :conf_variables, :kind_of => Hash, :default => {}
 attribute :conf, :kind_of => String
 attribute :conf_cookbook, :kind_of => String
 attribute :conf_variables, :kind_of => Hash, :default => {}
+attribute :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true
 
 
-def initialize(*args)
-  super
-  notifies :restart, "service[munin-node]"
+def after_created
+  notifies :restart, "service[munin-node]" if restart_munin
 end
 end
index e4b99965db78ee7d8e7c8399e8b40dacee2b960b..e47b1336ba5ed4e075bbebc35ad8dc5d018fc491 100644 (file)
@@ -24,12 +24,8 @@ attribute :name, :kind_of => String, :name_attribute => true
 attribute :cookbook, :kind_of => String
 attribute :template, :kind_of => String, :required => true
 attribute :variables, :kind_of => Hash, :default => {}
 attribute :cookbook, :kind_of => String
 attribute :template, :kind_of => String, :required => true
 attribute :variables, :kind_of => Hash, :default => {}
+attribute :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true
 
 
-def initialize(*args)
-  super
-  begin
-    resources(:service => "munin-node").subscrbes(:restart, self)
-  rescue Chef::Exceptions::ResourceNotFound
-    # Ignore
-  end
+def after_created
+  notifies :restart, "service[munin-node]" if restart_munin
 end
 end