我想在運行時根據一定條件中止配方,但使用提高或廚師:: 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