我应该使用include_recipe还是将配方添加到run_list? [英] Should I use include_recipe or add the recipe to run_list?

查看:104
本文介绍了我应该使用include_recipe还是将配方添加到run_list?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图找出大型项目的最佳方法。什么时候通过使用 include_recipe 在食谱中添加食谱,而不是将食谱添加到 run_list 相对合适?有很好的经验法则吗?

Trying to figure out the best approach for a large project. When is it appropriate to add recipes within a recipe by using include_recipe as opposed to adding the recipe to the run_list? Is there a good rule of thumb?

推荐答案

如我所见,任何配方都应该能够在空的机器上运行它自己的。因此,如果某些配方A取决于之前运行的配方B,我将始终使用include_recipe。

As I see it, any recipe should be able to run on an empty machine on its own. So if some recipe A depends on recipe B run before it, I always use include_recipe.

例如:2本食谱,tomcat和Java。 Tomcat需要Java。

For example: 2 cookbooks, tomcat and java. Tomcat requires java.


  1. 当某些用户想要安装tomcat时,他可能不知道自己实际上还需要其他食谱来安装安装它。他运行了tomcat配方,但失败了,并显示了一些完全无用的错误消息,例如找不到Java,甚至更糟-它成功了,但是用户当然不能启动tomcat,因为他没有安装Java。

  1. When some user wants to install tomcat, he may have no idea that he actually requires some other cookbook to install it. He runs the tomcat recipe and either it fails with some completely unhelpful error message like "No java found" or even worse - it succeeds, but then of course the user cannot start tomcat, because he does not have java installed.

但是当tomcat食谱中有 include_recipe'java'行时,它也需要取决于元数据中的'java'行,用户在尝试安装tomcat时,将看到可以理解的错误消息:未找到Cookbook Java。这样,用户实际上可以自己下载依赖项(甚至使用某些自动工具),而无需实际运行配方,而是读取元数据。

But when there is a include_recipe 'java' line in tomcat cookbook, which also requires a depends 'java' line in metadata, the user when trying to install tomcat, will see the understandable error message: "the cookbook java not found". This way actually user can download dependencies on his own (or even with some automatic tool) without actually running recipes, but reading metadata.

这篇关于我应该使用include_recipe还是将配方添加到run_list?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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