Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Use knife cookbook site install, which resolves dependencies.

share|improve this answer
    
Is there a way to do this without having my cookbooks in a git repository? –  Jeff V Jan 14 '13 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. –  Maciej Pasternacki Jan 15 '13 at 10:59
    
Accepting this one as it is the built in functionality I was thinking existed. –  Jeff V Jan 15 '13 at 19:57

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|improve this answer
    
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 '13 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. –  Holger Just Jan 14 '13 at 19:58
    
Thanks, this works for me! –  Jeff V Jan 15 '13 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 –  Jigar Joshi Jul 24 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. –  Holger Just Jul 24 at 17:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.