Whats the "right" way to use supermarket?

So whats the preferred method to use community cookbooks? Is it just download/untar/upload? Can chef-client use my metadata.rb and a Berksfile to just pull them at runtime?

1 Like

add the community cook book to you Berksfile

source 'https://supermarket.chef.io'

cookbook 'iis', '~> 4.1.6'
cookbook 'windows', '~> 1.39.1'
cookbook 'dotnetframework', '~> 1.2.0'
cookbook 'msoffice', '~> 0.1.0'
cookbook 'firewall', '~> 2.5.0'

Then add a depends to your metadata.rb

depends 'dotnet', '~> 2.1.0'
depends 'dotnetframework', '~> 1.2.0'
depends 'iis', '~> 4.1.6'
depends 'firewall', '~> 2.5.0'
depends 'windows', '~> 1.39.1'

That should do it, hope that helps… :slight_smile:

Hi Robert,

We have these main types of cookbooks

  • Application
  • Library
  • Wrapper
  • Environment

In most cases we add a dependency in the metadata.rb file and use Berkshelf to resolve the dependencies by setting the source to http://supermarket.chef.io (we actually run a private supermarket and a minimart).

Test kitchen detects the Berksfile which in turn resolves everything for us.

However there are some cases where we want a cookbook to be included in a Test Kitchen run but NOT to be a dependency of the Cookbook under test, in those cases we add those to just the Berksfile and include in the Test suite run list, e.g a line in the Berksfile similar to below

cookbook '<cookbook_name>', <location> 

The cookbook location can be local file system or github.

Two points to note:

Hope this helps

Hi @kxmoss

NB: You do not need to add the cookbooks and versions in the Berksfile, the metadata line in the Berksfile pulls in the metadata.rb file and reads in the dependencies, it will try and get those using the sources defined in the Berksfile.

If your cookbook comes from a specific source you can use that instead, i.e.

source 'https://supermarket.chef.io'


cookbook 'really_cool_cookbook', git: 'https://github.com/cookbooks/really_cool_cookbook'

Berkshelf will look for a Berkshelf endpoint, currently I think that is a Berks API server (old), Supermarket, Minimart although I believe there are plans to make the Chef server a Berkshelf / universe endpoint too,

Ahh, nice, I did not know that, I always put it in the it in Berksfile…:grinning:

The newer Chef servers work with Berkshelf using:

source :chef_server

Nathan Clemons
DevOps Engineer
Moxie Cloud Services (MCS)

O +1.425.467.5075
M +1.360.861.6291
E nclemons@gomoxie.com
W www.gomoxie.comhttp://www.gomoxie.com/



Totally missed that, Chef Server has a universe end point too. (yay!)