From e54da9eaec238be8640da3ebc26677969a316db1 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 10 Feb 2015 10:18:34 +0000 Subject: [PATCH] Clean up notification handling for the munin LWRPs --- cookbooks/munin/providers/plugin.rb | 2 ++ cookbooks/munin/resources/plugin.rb | 6 +++--- cookbooks/munin/resources/plugin_conf.rb | 10 +++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cookbooks/munin/providers/plugin.rb b/cookbooks/munin/providers/plugin.rb index e469acb6d..bcbb07746 100644 --- a/cookbooks/munin/providers/plugin.rb +++ b/cookbooks/munin/providers/plugin.rb @@ -39,6 +39,7 @@ action :create do cookbook new_resource.conf_cookbook template new_resource.conf variables new_resource.conf_variables + restart_munin false end end end @@ -51,6 +52,7 @@ action :delete do if new_resource.conf # ~FC023 munin_plugin_conf new_resource.name do action :delete + restart_munin false end end end diff --git a/cookbooks/munin/resources/plugin.rb b/cookbooks/munin/resources/plugin.rb index 5d36e13a5..d8861fafe 100644 --- a/cookbooks/munin/resources/plugin.rb +++ b/cookbooks/munin/resources/plugin.rb @@ -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 :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 diff --git a/cookbooks/munin/resources/plugin_conf.rb b/cookbooks/munin/resources/plugin_conf.rb index e4b99965d..e47b1336b 100644 --- a/cookbooks/munin/resources/plugin_conf.rb +++ b/cookbooks/munin/resources/plugin_conf.rb @@ -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 :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 -- 2.43.2