Chef cookbook dependencies of dependencies

5,625

Solution 1

Use knife cookbook site install, which resolves dependencies.

Solution 2

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
Share:
5,625

Related videos on Youtube

Jeff V
Author by

Jeff V

Updated on September 18, 2022

Comments

  • Jeff V
    Jeff V over 1 year

    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?

  • Jeff V
    Jeff V over 11 years
    Is there a way to do this without having my cookbooks in a git repository?
  • Jeff V
    Jeff V over 11 years
    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?
  • Holger Just
    Holger Just over 11 years
    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.
  • Maciej Pasternacki
    Maciej Pasternacki over 11 years
    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.
  • Jeff V
    Jeff V over 11 years
    Accepting this one as it is the built in functionality I was thinking existed.
  • jmj
    jmj almost 10 years
    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
  • Holger Just
    Holger Just almost 10 years
    @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.
  • jmj
    jmj almost 10 years
    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
  • Admin
    Admin over 8 years
    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.