Chef 'cookbook' in Berksfile vs 'depends' in metadata.rb

What is the difference between adding cookbooks to a Berksfile using a cookbook and adding cookbooks to metadata.rb using a "depends"? For example, if I add to metadata.rb

depends 'nginx' 

I need to add it to Berksfile using

 cookbook 'nginx' 

?

+52
chef berkshelf berksfile
Aug 16 '14 at 18:20
source share
2 answers

Berksfile is Berkshelf, and the metadata file is embedded in the chef.

Adding dependencies to the metadata file allows other applications, such as the librarian chef or supermarket, to read your dependencies.

Note that Berkshelf also reads dependencies from metadata while you add the metadata string to Berksfile.

I highly recommend listing all the dependencies in your metadata file and using your Berksfile to indicate where certain cookbooks are stored if they are not available at the supermarket (like Github or the local path).

+63
Aug 16 '14 at 18:37
source share

Berksfile and metadata.rb have different goals for the solution and enter the picture at different stages of the cookbook life cycle.

  • Berksfile is a dependency management tool for cookbooks. Consider the case where my cookbook uses the culinary community of a chef's supermarket . In this case, I first need to download this community cookbook from the supermarket and upload it, along with my own cookbook, to the chef's server. Berksfile simplifies this workflow for you. With a single command ( berks install ), it downloads all dependent cookbooks (and their dependent cookbooks are transitive dependencies) from their respective sources (maybe from a git repository or from a supermarket). With a single berks upload command, she uploads all of these cookbooks to the chef's server. You do not need to upload them separately with a knife cookbook upload . The Berksfile role, in particular, completes the life cycle of cookbooks.

  • metadata.rb is passed by the chef, actually converting node. It uses this file to download all the necessary cookbooks from the chef server (provided that these cookbooks are now available on the chef server using berkshelf or knife ) for node to successfully complete the work of the chef.

+10
Mar 31 '16 at 10:33
source share



All Articles