简体   繁体   English

在同一本食谱中使用多个食谱

[英]Using multiple recipes in same cookbook

I have a chef cookbook with four recipes. 我有一个厨师食谱,有四个食谱。 Each recipe configures a web application: 每个配方都配置一个Web应用程序:

myCookbook
   |
   |_ _ recipes
       |_ _ default.rb
       |_ _ app1.rb
       |_ _ app2.rb
       |_ _ app3.rb
       |_ _ app4.rb

I've configured this cookbook to update apps based on a default.rb recipe that just iterates over the other web app recipes and runs them. 我已经将这本食谱配置为基于default.rb配方更新应用程序,该配方只是迭代其他Web应用程序配方并运行它们。 The cookbook is kicked off by updated web app version in a data bag. 该手册由数据包中更新的网络应用程序版本启动。

Because I put all the apps into one cookbook, if I want to update one app then I have to update them all. 因为我将所有应用程序放入一本食谱中,如果我想更新一个应用程序,那么我必须全部更新它们。 I can manually override the runlist to just deploy one app, but is there a way to "knife diff" the data bag in the default recipe (or something like that) to only run the corresponding recipe of the web app version that was updated? 我可以手动覆盖运行列表以仅部署一个应用程序,但有没有办法在默认配方(或类似的东西)中“刀差”数据包只运行已更新的Web应用程序版本的相应配方?

You would have to implement the diff yourself using a local copy for idempotence tracking. 您必须使用本地副本进行幂等跟踪来实现差异。 Overall I would recommend reworking your recipes to be idempotent and convergent themselves. 总的来说,我建议将你的食谱重新设计为幂等的并且自己收敛。

You should write self convergent recipes instead of this. 您应该编写自收敛配方而不是此。

If the main reason behind using an external recipe (The default one) here is to avoid writing the same code over and over all recipes (The code that updates the app), you should try writing then a library or a custom resource that will be available for all your app recipes to use. 如果在这里使用外部配方(默认配方)背后的主要原因是避免在所有配方(更新应用程序的代码)上反复编写相同的代码,那么您应该尝试编写一个自定义资源 。可用于您使用的所有应用程序配方。

Online chef documentation has enough information about doing this, also it is quite easy if you have basic Ruby knowledge. 在线厨师文档提供了有关此操作的足够信息,如果您具有基本的Ruby知识,也很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM