[英]ruby_block conditional statement and waiting for reboot
我從CODE廚師的IRC上得到了很好的指導,我不想再煩他了,但這是我的問題:
我的目標是先運行配方,然后運行兩個,然后在保持主廚運行的同時重新啟動,然后執行配方三。 我想我已經接近了,但仍然遇到錯誤。 我不確定這是我的代碼塊還是Windows的行為方式。
這是我的代碼塊:
ruby_block "test" do
block do
run_context.include_recipe "stuff::reboot"
while reboot_pending? == true do
run_context.include_recipe "stuff::three"
end
end
end
該塊執行沒有問題,但它似乎很快進入了東西::三個配方,這會導致此錯誤,因為由於機器仍在啟動,因此無法使用powershell:
==> default: The argument 'c:/tmp/vagrant-elevated-shell.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
我在想,一旦發出重新啟動命令,幾秒鍾后將不再有待處理的重新啟動。 那么,有沒有其他的紅寶石助手可以和我一起使用? 還是這只是垃圾?
太好了,我也在這里回答了很多問題。 謝謝你的想法。
您一直試圖將include_recipe
放入while循環的主體中,這不是我想不到的。 這就是說:“在重新啟動掛起時,一遍又一遍地包含此內容”。
您想要的是:
include_recipe 'stuff::reboot'
ruby_block 'wait for reboot' do
block do
true while reboot_pending?
end
end
include_recipe 'stuff::three'
這將在兩個配方中的東西之間的集合中放置資源,如果重啟未決,則將停止聚合,否則它將繼續。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.