Chef infra 如何仅在使用包资源的:升级选项时重新启动服务

Chef infra 如何仅在使用包资源的:升级选项时重新启动服务,chef-infra,Chef Infra,使用厨师食谱中的包资源和:升级选项,我想确保我的服务只有在实际升级时才重新启动 看来这是不可能的。是否有方法仅在该事件中触发部分代码 # 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

使用厨师食谱中的资源和:升级选项,我想确保我的服务只有在实际升级时才重新启动

看来这是不可能的。是否有方法仅在该事件中触发部分代码

# 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
#安装或更新程序包blahblah
包“blahblah”do
行动:升级
结束
#确保服务处于活动状态
服务“blahblah”do
行动:开始
结束
#要仅调用升级后的包,请使用通知

package 'foo' do
  notifies :restart, 'service[foo]'
end 
使用通知

package 'foo' do
  notifies :restart, 'service[foo]'
end 

你试过这个通知序列吗

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

你试过这个通知序列吗

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

我从程序包“blahblah”中得到了3个结果:a)程序包未安装,因此它会安装它b)程序包已安装,无需升级c)程序包已安装,并针对“a”执行了升级它应针对“b”执行服务启动关于“c”不需要任何其他内容需要重新启动服务,那么如何在您建议的通知中包含上述条件方面呢?我们通常只在初始安装时接受额外的重新启动,因为防止它是一件事半功倍的事情。我从包“blahblah”中得到了3个结果:a)包未安装,因此,它会安装b)安装了软件包,无需升级c)安装了软件包,并针对“a”执行了升级它应该针对“b”执行服务启动关于“c”不需要任何其他内容需要重新启动服务,那么如何在您建议的通知中具有上述条件方面呢?我们通常只在初始安装时接受额外的重新启动,因为防止它是一件事半功倍的事情。