How apply chef cookbook/recipes to multiple nodes?

a 夏天 提交于 2019-12-11 23:15:55

问题


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. 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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/27353595/how-apply-chef-cookbook-recipes-to-multiple-nodes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!