chef-infra - 我应该使用 include_recipe 还是将配方添加到 run_list 中?

标签 chef-infra recipe chef-recipe

尝试找出大型项目的最佳方法。什么时候适合使用 include_recipe 在配方中添加配方,而不是将配方添加到 run_list 中?有没有好的经验法则?

最佳答案

据我所知,任何配方都应该能够在自己的空机器上运行。因此,如果某些配方 A 依赖于在其之前运行的配方 B,我总是使用 include_recipe。

例如:2 本 cooking 书、tomcat 和 java。 Tomcat 需要 java。

  1. 当某些用户想要安装 tomcat 时,他可能不知道他实际上需要其他一些说明书来安装它。他运行 tomcat 配方,要么失败,并出现一些完全无用的错误消息,例如“未找到 java”,或者更糟糕 - 它成功了,但用户当然无法启动 tomcat,因为他没有安装 java。

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

关于chef-infra - 我应该使用 include_recipe 还是将配方添加到 run_list 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16947393/

相关文章:

backbone.js - 您对主干.js 项目的最佳实践是什么?

makefile - GNU 制作空配方与无配方

linux - Chef 生成菜谱

chef-infra - Chef 属性 : does file name matter?

azure - Knife Azure 创建 VM 失败 - 等待 WinRM

chef-infra - Chef 与所有者递归创建目录

configuration-management - Cfengine 与 Chef

chef-infra - 为什么 Chef 不能解决我的 Recipe ?

ruby - Chef LWRP 的属性方法是什么?我可以传递什么?

variables - 如何在 bitbake/yocto 中转义 "$"?