"include_recipe" vs.Vagrantfile"chef.add_recipe".有什么不同? [英] "include_recipe" vs. Vagrantfile "chef.add_recipe". What's the difference?

查看:97
本文介绍了"include_recipe" vs.Vagrantfile"chef.add_recipe".有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需在我无业游民的盒子上运行nginx :: source食谱,我的行为就会非常异常.

Just ran nginx::source recipe on my vagrant box, and I have very unusual behaviour.

当我包含 Vagrantfile (如下所示)中的食谱时,一切都像一个咒语,

When I include a recipe from the Vagrantfile (as below), everything works like a charm,

chef.add_recipe("project :: nginx")
Chef.add_recipe("nginx :: source")

chef.add_recipe("project::nginx")
chef.add_recipe("nginx::source")

( project :: nginx 食谱非常简单.使用它来覆盖nginx食谱的默认属性)

(project::nginx recipe is very simple. Using it to override default attributes of the nginx cookbook)

但是,如果我在 project :: nginx (最后提到)的末尾添加了食谱,一切都会崩溃:

but if I include a recipe at the very end of project::nginx (mentioned up), everything falls apart:

node.default['nginx']['server_names_hash_bucket_size'] = 128
include_recipe "nginx::source"

直到现在,我还不知道这两个调用在行为上有什么区别.这里有人知道有什么区别吗?

推荐答案

Gotya! Chef 11功能.问题仅在chef-solo中存在:)

Gotya! Chef 11 feature. Issue with it exist in chef-solo solely :)

要快速恢复,区别是:

  • chef.add_recipe()-加载整个菜谱上下文(所有文件,例如配方,定义,属性...)
  • include_recipe"-不在扩展运行列表中的文件(属性,定义等)不会被加载.

至少有4种方法可以解决此问题(将文件放入运行列表):

There are at least 4 ways to solve the issue(put files in the run list):

  • include_attribute-明确包含所需的属性文件.
  • metadata.rb->依赖关系-如果您的食谱正在使用另一本食谱的食谱,请将该食谱放入metadata.rb的依赖项部分,然后将加载其所有文件.
  • chef.add_recipe()-通过Vagrantfile加载配方. (此处提及仅供参考)
  • Berkshelf-您也可以使用此食谱管理器来解决此问题.这是关于此确切问题的 Stackoverflow线程一些文档
  • include_attribute - include desired attribute file explicitly.
  • metadata.rb->dependency - if your cookbook is using recipe from another cookbook, put that cookbook in metadata.rb's dependency section, and all it's files will be loaded.
  • chef.add_recipe() - Load recipe via Vagrantfile. (Mentioned here just for reference)
  • Berkshelf - you may use this cookbook manager to solve the issue as well. Here's the Stackoverflow thread about this exact problem and some Docs

对于那些对进一步阅读感兴趣的人,Chef 11引入了针对非食谱文件的基于依赖的食谱加载.新的加载逻辑意味着将不再加载属于cookbook_path中但不存在于扩展run_list中或不存在于扩展run_list中的烹饪书的依赖关系的属于烹饪书的文件. REF: Oscode打破更改文档,并且如果您需要我收到的错误的签名,请这里是完全一样的,甚至出于同样的原因.

For those who are interested in further reading, Chef 11 introduced dependency-based cookbook loading for non-recipe files. The new loading logic means that files belonging to cookbooks which exist in the cookbook_path but are not in the expanded run_list or dependencies of the cookbooks in the expanded run_list will no longer be loaded. REF: Opscode breaking changes documentation, and if you need a signature of the error I got, here's the exactly same one, even for the same cause.

这篇关于"include_recipe" vs.Vagrantfile"chef.add_recipe".有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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