2

I have a chef repository containing many cookbooks, and a Berksfile containing the following:

Dir.glob('cookbooks/*/').each do |path|
    cookbook File.basename(path), :path => path
end

cookbook 'supervisor', '~> 0.5.1', :github => "opscode-cookbooks/supervisor"

This includes each cookbook from the repository, and an external cookbook from a github repository. By default, Berkshelf searches the opscode community site for any cookbooks that are not listed.

Instead of this, I would either like to:

  • Disable this default, and never search an external site for missing dependencies.
  • Replace this default with a local path, so that I can remove the Dir.glob that adds each of my local cookbooks.

As a side note, I'm fully aware that keeping cookbooks in the chef repository is considered an anti-pattern. It's not something I can change in this situation, and while Berkshelf is not designed to handle this, being able to turn of the default site so that no cookbooks are implicitly pulled in from an source the user does not control is still useful.

borntyping
  • 2,931
  • 2
  • 23
  • 30

1 Answers1

2

Berkshelf appears to use the opscode community site as it's default location, so you could try setting a dummy site value. The ideas is that a missing dependency would throw a time-out error.

A better approach, in my opinion, is to operate your own cookbook repository, using a dedicated hosted chef organisation or open source chef server:

chef_api "https://api.opscode.com/organizations/myrepo", node_name: "repo", client_key: "/path/to/repo.pem"

cookbook 'myapp'
cookbook 'supervisor', '~> 0.5.1', :github => "opscode-cookbooks/supervisor"

The dependencies of the "myapp" cookbook would not need to be explicitly listed, instead they are downloaded as transitive dependencies from your custom repo.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185