Chef cookbook dependencies of dependencies
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
Related videos on Youtube
Jeff V
Updated on September 18, 2022Comments
-
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 over 11 yearsIs there a way to do this without having my cookbooks in a git repository?
-
Jeff V over 11 yearsWhat 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 over 11 yearsBoth 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 yourCheffile
orBerksfile
. -
Maciej Pasternacki over 11 yearsNot 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 over 11 yearsAccepting this one as it is the built in functionality I was thinking existed.
-
jmj almost 10 yearshow about download ? I couldn't find a clean way to download cookbook with dependencies, for example if I do
knife cookbook download A
andA
depends onB
, it doesn't downloadB
-
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 almost 10 yearsI am using berkshelf, I download cookbook using
knife cookbook download A
and then if I runberks install
orberks package
it fails because it tries to find its dependencyB
in the same directory -
Admin over 8 yearsThis 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.