我不想每次 Chef 客户端在我的应用主机上运行时都运行 bundle install
我有一个 bundle check
执行资源,它会通知 bundle install
资源(如果捆绑检查失败)
execute "bundle_check" do
cwd node[:app][:install_dir]
user "foo"
command 'bundle check'
action :run
returns [1]
notifies :run, "execute[bundle_install]", :immediately
ignore_failure true
end
我设置了 ignore_failure true
属性,但我想知道是否有一种方法可以配置 notizes
属性以根据返回值进行通知。本质上,我不希望 bundle check
的任何一个返回值被视为失败,并且我只想通知该值是否为 1。
最佳答案
您对通知的理解有误。在这种情况下你真正想要的是 Resource Guard在安装资源上:
command 'bundle install' do
# ... existing parameters
not_if 'bundle check'
end
这将执行外壳防护,然后仅在bundle check
失败(返回非零)时运行bundle install
命令。
关于chef-infra - Chef : notify based on `execute` result failure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22720457/