【发布时间】:2014-12-23 00:43:04
【问题描述】:
我想根据特定条件在运行时中止配方,但使用 raise 或 Chef::Application.fatal!,如本文@987654321 中所述@我的配方仅在编译时退出。
这是我正在尝试的(我的脚本的一部分):
execute "Execute somehthing" do
cwd node['abc']['dir']
command "something >> #{results}"
node.default['success'] = "false"
notifies :run, "ruby_block[jobFailure]", :delayed
not_if "cd #{node['abc']['dir']} && somecommand >> #{results}"
end
ruby_block "jobFailure" do
raise "Exiting the script as the job has failed" if (node.default['success'] == "false")
action :nothing
end
但是在运行上述脚本时,我收到了错误,因为 Chef 在编译时退出,只给出以下错误:
Running handlers:
[2014-10-27T17:17:03+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-27T17:17:03+00:00] ERROR: Exception handlers complete
[2014-10-27T17:17:03+00:00] FATAL: Stacktrace dumped to c:/Users/manish.a.joshi/
.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 12.400772 seconds
[2014-10-27T17:17:03+00:00] FATAL: RuntimeError: Exiting the script as the job has failed
谁能告诉我是否有办法只根据条件执行 raise 命令?
【问题讨论】:
-
不清楚你的情况。您能否编辑您的问题以澄清您正在检查的条件是什么?
标签: continuous-integration chef-infra