I am attempting to use berkshelf with chef to provision a Vagrant machine. This is running on Windows 7. I installed Berkshelf as part of the Chef-DK. It reports version 3.2.3. My vagrant provisioning was failing because it cannot find some cookbooks. Here is the relevant bit of my Berksfile
source "https://api.opscode.com/organizations/createthegood"
#source "https://api.berkshelf.com"
metadata
cookbook "drupal_site"
cookbook "al_base"
When I run a berks install, it fails to index the source:
D:\Rob\VMs\ctg_cookbook>berks install
Resolving cookbook dependencies...
Fetching 'artifact' from git://github.com/RiotGames/artifact-cookbook.git (at master)
Fetching 'ctg_cookbook' from source at .
Fetching 'drush' from git://github.com/jenkinslaw/chef-drush.git (at 0a567e2)
Fetching 'php-fpm' from git://github.com/yevgenko/cookbook-php-fpm.git (at master)
Fetching cookbook index from https://api.opscode.com/organizations/createthegood...
D:/opscode/chefdk/embedded/lib/ruby/gems/2.0.0/gems/berkshelf-api-client-1.2.1/lib/berkshelf/api
_client/connection.rb:67:in `block in universe': undefined method `each' for #<String:0x3fdc4e8>
(NoMethodError)
from D:/opscode/chefdk/embedded/lib/ruby/gems/2.0.0/gems/berkshelf-api-client-1.2.1/lib/
berkshelf/api_client/connection.rb:66:in `tap'
from D:/opscode/chefdk/embedded/lib/ruby/gems/2.0.0/gems/berkshelf-api-client-1.2.1/lib/
berkshelf/api_client/connection.rb:66:in `universe'
from D:/opscode/chefdk/embedded/apps/berkshelf/lib/berkshelf/source.rb:22:in `build_univ
erse'
from D:/opscode/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:21:in `block (
2 levels) in build_universe'
However, knife finds that cookbook on its configured server:
C:\Users\29007>knife cookbook list help
7-zip 1.0.2
activelamp_composer 0.0.1
activelamp_drupal 0.0.4
activelamp_symfony 0.0.1
al_base 0.0.1
I thought that perhaps it berkshelf wasn't picking up on the configuration info from knife (like the keyfiles, perhaps). But I can't seem to come up with a way to verify that. What's my next step in trying to diagnose this?
I don't believe Hosted Chef provides a Berkshelf API that you can use inside your Berksfile. Berkshelf needs to talk to a berkshelf-api, which indexes all your Chef Server's cookbooks and then is able to do dependency resolution. This is why the block in universe
fails because there's a /universe
API resource in the berkshelf-api. It looks like Hosted Chef doesn't support it.
Normally in your Berksfile you put your internal berkshelf-api first and put the community berkshelf-api second. In this case, the community api is now at https://supermarket.chef.io. If your cookbooks only depend on cookbooks available on Supermarket, you won't have to set up your own Berkshelf API.
If you do plan on writing cookbooks that depend on your own cookbooks, the best approach would be to set up a berkshelf-api server. There's a cookbook and you can set it up and point it at your Hosted Chef organization. You could also set up your own supermarket which also provides a Berkshelf API.