Skip to content

Instantly share code, notes, and snippets.

@bijugs
Last active August 29, 2015 14:19
Show Gist options
  • Save bijugs/c1fac5aad933c4380b0a to your computer and use it in GitHub Desktop.
Save bijugs/c1fac5aad933c4380b0a to your computer and use it in GitHub Desktop.
# I'm not sure if this is a good approach as I've not been working heavily with chef recently.
# However this was an approach that we used to clear notifications from cookbooks when
# using wrapper cookbooks. (worked in Chef 11)
#
# There are now probably better approaches for writing re-usable cookbooks:
# http://www.slideshare.net/someara/cookbook-reusability-chef-community-summit-2014
## cookbook1::example.rb
#
# Here we define a template with an immediate restart
template '/some/example/template.conf' do
source 'template.conf.erb'
notifies :restart, 'service[example]', :immediately
end
## cookbook2::default.rb
# This is our 'wrapper' cookbook
#
include_recipe 'cookbook1::example'
# Load the template resource
our_template = resources('template[/some/example/template.conf]')
# Clear the immediate_notifications from the resource
# (there may also be delayed_notifications, you'd need to check the code)
our_template.immediate_notifications.clear
# Then add any new notifications you may want.
our_template.notifies :restart, 'service[some_other_service]', :delayed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment