chef-infra - Chef : notify based on `execute` result failure

标签 chef-infra

我不想每次 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/

相关文章:

chef-infra - 如何理解Chef中的通知和订阅?

chef-infra - Chef 如何将多个成员添加到组中

mysql - 从 Chef Recipe 安装本地放置的软件包 (.rpm)

python - 如何使用 Chef 和 python_pip 联系特定的 pypi 服务器

ruby - 用chef创建windows用户,并将用户添加到本地Administrators组

chef-infra - 检查 Chef 是否以 Chef 独奏身份运行

cron - Chef - 重复 Recipe 执行

templates - 相当于Glu中的Chef模板

chef-infra - Chef Vault 项目未使用您的公钥加密

chef-infra - etcd/zookeeper/consul 和其他配置管理工具(如 chef/puppet/..)之间的关系?