如何将厨师食谱/食谱应用于多个节点? [英] How apply chef cookbook/recipes to multiple nodes?

查看:102
本文介绍了如何将厨师食谱/食谱应用于多个节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处是如何将食谱应用于Chef的示例。但是没有任何关于多个节点的信息。例如,我有一个akka应用程序,该应用程序通过 akka.cluster.seed-nodes 参数传递。因此算法应为:

Here is example how apply cookbook to node with Chef. But nothing told about multiple nodes. For example I have a akka application, which is passed akka.cluster.seed-nodes parameters. So the algorithm should be:


  1. 使用IP地址定义数组 IP,例如[192.168.1.1],[192.168.1.2],[ 192.168.1.3]

  2. 定义带有引导IP地址的空数组 bootsrapped

  3. 通过 IP开始迭代

  4. 使用当前ip调用刀引导程序,并通过 bootsrapped -Dakka.cluster.seed-nodes

  5. 将增强型ip存储在第二个数组中

  6. 转到3

  1. Define array "IP" with ip addresses like [192.168.1.1], [192.168.1.2], [192.168.1.3]
  2. Define empty array "bootsrapped" with bootsrapped ip addresses
  3. starting iteration over "IP"
  4. invoke knife bootstrap with current ip and "pass" -Dakka.cluster.seed-nodes with "bootsrapped" values
  5. store boostrapped ip in second array
  6. go to 3

因此,目标是编写一个可以从服务器应用到多个节点的脚本。厨师如何做?

So the goal is to write a script that can be applied to several nodes from sever. How do so with chef?

推荐答案

您不会在服务器端执行此操作。实际上,服务器甚至没有将配方应用于单个节点。如果要在其上运行具有相同配方的多个厨师节点,则只需创建多个厨师节点,然后为它们提供相同的run_list。您可以将这些食谱打包成一个角色,但这并不会改变单独定义每个食谱的需要。

You wouldn't do this on the server side. In fact, the server doesn't even apply a recipe to a single node. If you want multiple chef nodes with the same recipes run on them, you would simply create multiple chef nodes and give them all the same run_list. You could package those recipes into a role, but that doesn't change the need to define each one individually.

如果要对它进行脚本处理,可以在工作站(运行刀的节点)上进行。您可以使用一个小脚本来遍历一系列IP并自举每个IP,也可以使用 Vagrant 在单个DSL文件中定义整个节点群集。

If you wanted to scrip this, you would do so on the workstation (the node you run knife from). You could either have a small script that iterates over an array of IPs and bootstraps each one, or you could use a tool like Vagrant to define a whole cluster of nodes in a single DSL file.

这篇关于如何将厨师食谱/食谱应用于多个节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆