How to use Berkshelf to manage Organization repo?

坚强是说给别人听的谎言 提交于 2019-12-23 09:48:30

问题


I'm a huge fan of Berkshelf and I've released few community cookbooks using it and its awesome.

Now, I'm starting a new chef project and I went ahead with Berkshelf for this too.

But I'm finding some confusions/difficulties using it for the project.

Following is in the Berksfile:

site :opscode

cookbook 'mediawiki', github: 'millisami/chef-mediawiki'
cookbook 'sp-mediawiki', path: 'site-cookbooks/sp-mediawiki'

I've generated my application cookbook inside the site-cookbooks folder.

When I do berks install, it errors out:

An error occurred while reading the Berksfile: no metadata.rb or metadata.json found at \
/Users/millisami/Code/chef-sp/site-cookbooks/sp-mediawiki

Now I'm wondering where do I generate my application sp-mediawiki cookbook?

If just create a new one berks cookbook sp-mediawiki, it will be similar to the library cookbook.

This sort of flow is perfectly done using librarian-chef which I am using on another project.

So, I'm trying to put a line that:

  1. Berkshelf is good to develop individual cookbooks
  2. Librarian-chef is good to manage the top-level orchestration

Am I right/wrong? How you folks use Berkshelf to manage your Org's chef-repo?


回答1:


As I said in my response on GitHub:

If you have a Berksfile at the top of your chef-repo, you can you Berkshelf to manage all your cookbook dependencies for you.

For example, let's say I'm writing an application cookbook that depends on the apache2 cookbook. I would add to my Berksfile:

site :opscode

cookbook 'apache2', '~> x.x.x' # optional version constraint

And run the berks install command to install this cookbook. Because it's a library, it's installed on your machine "somewhere" and you shouldn't bother finding it. Now, you generate your application-cookbook (let's call it my-apache2):

$ berks cookbook my-apache2

And this will create the skeleton for you. Then you can add apache2 as a dependency on this new cookbook in the metadata.rb:

name 'my-apache2'
# suppressed
version '1.0.0'

depends 'apache2'

And your directory structure looks like:

chef-repo
  |  Berksfile
  |_ cookbooks
    |_ my-apache2

Notice the apache cookbook is not there. The library cookbooks all live in ~/.berkshelf/cookbooks, but you shouldn't worry about that. They are automatically pulled in and added to your path for you.

If another teammate wants to use your chef-repo, simply have them run berks install and all the necessary dependencies will be installed on their machine as well.

When you run commands like berks upload, Berkshelf will automatically find and resolve all the necessary cookbooks for you.

Does this make sense?




回答2:


I believe this got answered here: https://github.com/RiotGames/berkshelf/issues/535



来源:https://stackoverflow.com/questions/16603326/how-to-use-berkshelf-to-manage-organization-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!