我想在运行时根据一定条件中止配方,但使用提高或厨师:: Application.fatal!如本文所述How do you abort/end a Chef run?我的食谱仅在编译时退出。中止厨师食谱在运行时不在编译期间
这里是我想(我的剧本的一部分):
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
但是在运行上面的脚本我得到的厨师是在编译时退出只给下面的错误的错误:
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命令吗?
目前尚不清楚你的条件是什么。你能否编辑你的问题来澄清你检查的条件是什么? – 2014-10-27 23:27:14