7

This might be a simple question - I am trying to install a cookbook (gitlab)

I cloned the cookbook into a folder on my local drive and ran

knife cookbook upload gitlab.

Immediately it threw an error:

Cookbook gitlab depends on cookbook postgresql version >= 0.0.0

So I ran

knife cookbook site download postgresql

It had some dependencies, which had further dependencies, and now I'm at the point where I am installing cookbooks I know I won't need (dmg, windows, etc.)

I was under the impression that this stuff automatically resolved itself like aptitude or yum. Did I miss some crucial step of a cookbook dependency resolver?

2 Answers 2

5

Use knife cookbook site install, which resolves dependencies.

4
  • 1
    Is there a way to do this without having my cookbooks in a git repository?
    – Jeff V
    Jan 14, 2013 at 19:11
  • Not with knife cookbook site install, it is tied to Git. As I use Git myself, I don't know whether Librarian or Berkshelf mentioned in Holger Just's answer work with other version control systems. Jan 15, 2013 at 10:59
  • Accepting this one as it is the built in functionality I was thinking existed.
    – Jeff V
    Jan 15, 2013 at 19:57
  • This doesn't avoid getting a bunch of cruft you don't need, and it doesn't use submodules which might integrate nicely in say vagrant in a cookbooks subdirectory... what I would find useful is a way to run chef but have it ignore dependencies all together, so I would only get error messages for cookbooks that would actually get used. I could then install only those.
    – user68729
    Nov 12, 2015 at 23:35
6

You could use one of the established cookbook dependency managers, i.e. either Librarian or Berkshelf.

Both of these tools is designed to retrieve cookbooks from the internet, e.g. from code repositories like github, or the community.opscode.com site and to put them onto your local system. These tolls will automatically resolve recursive dependencies and version requirements and pull all required cookbooks down. Once you have all these available locally, you can then upload them all to the server, e.g. by using

knife cookbook upload -a
6
  • What I couldn't figure out with either of these, is if I am trying to use a 3rd party cookbook, and it doesn't have any support for Librarian or Berkshelf, will that break things?
    – Jeff V
    Jan 14, 2013 at 19:43
  • 3
    Both of these tools use the metadata.rb file for dependency management which should be present in each cookbook anyway (as it is required by chef server). So no, most of the time, you don't need to do anything special in your cookbook. The only possible exception is if you have dependencies which are not available on community.opscode.com. Then you need to explicitly state where to find those in your Cheffile or Berksfile. Jan 14, 2013 at 19:58
  • how about download ? I couldn't find a clean way to download cookbook with dependencies, for example if I do knife cookbook download A and A depends on B, it doesn't download B Jul 24, 2014 at 17:14
  • @JigarJoshi As I said in my answer, you should use a dependency manager for cookbooks which is able to resolve the dependencies and download all the required cookbooks. Most people use Berkshelf nowadays. But personally, I still prefer librarian-chef. Jul 24, 2014 at 17:27
  • I am using berkshelf, I download cookbook using knife cookbook download A and then if I run berks install or berks package it fails because it tries to find its dependency B in the same directory Jul 24, 2014 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .