在Chef配方中,我需要在执行某些操作后在节点上执行重新启动,
重启完成后,我需要继续执行其他操作:
食谱:
– 行动1
– 动作2
-重启
-action3
-action4 ….
我已经检查了社区中的一些现有食谱:reboot-handler,chef-reboot,chef-restart,chef-dominous,但我不能让它们中的任何一个工作.
在Chef中有一些方法可以得到我需要的东西吗?
请提供详细的例子.
非常感谢您的帮助.
最佳答案 如何使用
chef tags实现一系列状态转换?这种方法可以与
reboot-handler食谱相结合来管理实际的重启.
例
default.rb
#
# Action recipes
#
include_recipe "mycookbook::action1"
include_recipe "mycookbook::action2"
#
# State transitions
#
if tagged?("doAction1")
untag("doAction1")
tag("doAction2")
elsif tagged?("doAction2")
untag("doAction2")
end
action1.rb
if tagged?("doAction1")
..
..
end
action2.rb
include_recipe "reboot-handler"
if tagged?("doAction2")
..
..
# Trigger reboot at end of chef run
node.run_state['reboot'] = true
end