-
Notifications
You must be signed in to change notification settings - Fork 71
If you want to use librarian-chef when developing a cookbook inside your repository, you can do one of two things:
First Option: You can put your cookbook into your site-cookbooks
directory, and make sure that knife knows about your site-cookbooks
directory (by adding that in your .chef/knife.rb
).
# .chef/knife.rb
# ... snip ...
require 'librarian/chef/integration/knife'
cookbook_path Librarian::Chef.install_path,
File.expand_path('../../site-cookbooks', __FILE__)
# ... snip ...
If you do this, you should not add that cookbook to your Cheffile
. Instead, you should make sure your cookbook has a correct metadata.rb
and you should duplicate the dependencies and their constraints in your cookbook's metadata.rb
into your Cheffile
. For example, if your cookbook's metadata.rb
declares depends "rabbitmq"
, then your Cheffile
should declare cookbook "rabbitmq"
. Note that librarian-chef will not know about your cookbook at all. But that is OK, since it's really part of your repository and not an external cookbook, and librarian-chef is really for pulling in external cookbooks. This is the simpler approach.
Second Option: You can put your cookbook into a separate directory such as cookbooks-sources
, which knife does not know about, and add the cookbook to your Cheffile
with the :path =>
source:
cookbook "my-wonderful-cookbook",
:path => 'cookbooks-sources'
If you do this, you should make sure that this directory is not added to your .chef/knife.rb
. The reason is that this technique treats your cookbook as an external cookbook which librarian-chef should pull in every time you run librarian-chef install
. Note that every time you change your cookbook, you will need to re-run librarian-chef install
to have librarian-chef install that cookbook into your cookbooks
directory before uploading the cookbook to the chef-server.
Akin to this technique, you can put your cookbook into a separate git repository and use the :git =>
source in your Cheffile
. You will need to run librarian-chef update my-wonderful-cookbook
whenever you push to your cookbook external git repository.
Whether you put your cookbook in a separate path or in an external git repository, be sure to declare all of your cookbook's dependencies in your cookbook's metadata.rb
so that librarian-chef can read them and pull down all the cookbooks that your cookbook depends on. If your cookbook depends on another cookbook which is found in a git repository but not on the Opscode Community Site, be sure to add an entry for that depended-on cookbook, with the source to pull it from, to your Cheffile
so that librarian-chef knows where to get that depended-on cookbook.