如何重命名配方并将其替换到所有节点的 运行 列表中
How do I rename a recipe and replace it on the run list of all nodes
假设我有一个名为 my_cookbook::recipe_old.rb
的食谱。此配方已应用于 运行 节点、角色等列表
但是假设我需要将食谱重命名为 recipe_new.rb
。如何更新所有节点和角色的 运行 列表?
我想我必须做一个 knife search
来找到应用了配方的所有节点和角色,将新命名的配方添加到它们的 运行 列表中,然后删除旧的来自他们 运行 列表的食谱。
这是最好的方法还是 Chef 对此有更好的解决方案?
像这样
knife exec -E 'nodes.transform("*:*") {|n| n.run_list.each_index {|i| if n.run_list[i] == "recipe[my_cookbook::recipe_old]"; n.run_list[i] = "recipe[my_cookbook::recipe_new"; return true; end } false }'
然后是 roles.transform
的类似内容。
假设我有一个名为 my_cookbook::recipe_old.rb
的食谱。此配方已应用于 运行 节点、角色等列表
但是假设我需要将食谱重命名为 recipe_new.rb
。如何更新所有节点和角色的 运行 列表?
我想我必须做一个 knife search
来找到应用了配方的所有节点和角色,将新命名的配方添加到它们的 运行 列表中,然后删除旧的来自他们 运行 列表的食谱。
这是最好的方法还是 Chef 对此有更好的解决方案?
像这样
knife exec -E 'nodes.transform("*:*") {|n| n.run_list.each_index {|i| if n.run_list[i] == "recipe[my_cookbook::recipe_old]"; n.run_list[i] = "recipe[my_cookbook::recipe_new"; return true; end } false }'
然后是 roles.transform
的类似内容。