“include_recipe” vs. Vagrantfile “chef.add_recipe”. What's the difference?

孤街浪徒 提交于 2019-12-03 07:35:17
Konzulic

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

To make a quick resume, difference is:

  • chef.add_recipe() - loads entire cookbook context (all the files, e.g. recipes, definitions, attributes...)
  • include_recipe "" - files(attributes, definitions etc.) that are not in the expended run list are not loaded.

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

  • 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

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.

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