Reputation: 8875
Using the package resource in a chef recipe, with the :upgrade option, I want to ensure that my sercvice is restarted only when it is actually upgraded.
It does not appear this is possible. Is there a way to trigger a part of code in that event only?
# installs or updates package blahblah
package 'blahblah' do
action :upgrade
end
# ensures the service is active
service 'blahblah' do
action :start
end
# TO BE INVOKED ONLY the package is upgraded <<<============
service 'blahblah' do
action :restart
end
Upvotes: 0
Views: 568
Reputation: 1231
Have you tried this notifications sequence?
package 'blahblah' do
action :upgrade
notifies :restart, "service[blahblah]", :immediately
end
package 'blahblah' do
action :install
notifies :start, "service[blahblah]", :immediately
end
service 'blahblah' do
action :nothing
end
Upvotes: 1
Reputation: 54191
Use a notification
package 'foo' do
notifies :restart, 'service[foo]'
end
Upvotes: 1