Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Berkshelf with Chef-solo?

I am trying to get going with Berkshelf to manage cookbooks. Here are the steps

$ berks init  # and use a custom Vagrant box image
$ vim Berksfile  # and put cookbook 'git'
$ berks install
$ vagrant up

I would expect the last step to provision the VM with the git cookbook, however I get:

$ bin/vagrant up
/Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/hashie-2.0.0/lib/hashie/mash.rb:80: warning: redefining `object_id' may cause serious problems
[default] Importing base box 'Ubuntu-11.04'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[Berkshelf] installing cookbooks...
[Berkshelf] Using git (2.3.0)
[Berkshelf] Using dmg (1.1.0)
[Berkshelf] Using build-essential (1.3.4)
[Berkshelf] Using yum (2.1.0)
[Berkshelf] Using windows (1.8.4)
[Berkshelf] Using chef_handler (1.1.4)
[Berkshelf] Using runit (1.0.6)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Setting host name...
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: Vagrant::Provisioners::ChefSolo...
[default] Generating chef JSON and uploading...
[default] Running chef-solo...
stdin: is not a tty
[2013-02-24T12:51:04+00:00] INFO: *** Chef 10.18.2 ***
[2013-02-24T12:51:05+00:00] INFO: Setting the run_list to ["recipe[berkshelf-test::default]"] from JSON
[2013-02-24T12:51:05+00:00] INFO: Run List is [recipe[berkshelf-test::default]]
[2013-02-24T12:51:05+00:00] INFO: Run List expands to [berkshelf-test::default]
[2013-02-24T12:51:05+00:00] INFO: Starting Chef Run for ubuntu-11.04
[2013-02-24T12:51:05+00:00] INFO: Running start handlers
[2013-02-24T12:51:05+00:00] INFO: Start handlers complete.
[2013-02-24T12:51:05+00:00] ERROR: Running exception handlers
[2013-02-24T12:51:05+00:00] ERROR: Exception handlers complete
[2013-02-24T12:51:05+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-02-24T12:51:05+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook berkshelf-test not found. If you're loading berkshelf-test from another cookbook, make sure you configure the dependency in your metadata
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

The chef-solo part in the Vagrantfile:

  config.vm.provision :chef_solo do |chef|
    chef.json = {
      :mysql => {
        :server_root_password => 'rootpass',
        :server_debian_password => 'debpass',
        :server_repl_password => 'replpass'
      }
    }

    chef.run_list = [
      "recipe[berkshelf-test::default]"
    ]
  end
like image 860
poseid Avatar asked Feb 24 '13 12:02

poseid


People also ask

What is Berks in Chef?

Berkshelf is a Command Line tool which can act as a source code management tool or a package manager like gem, apt, yum, etc. It replaces portions of knife like generating, uploading & downloading Cookbooks.

What is metadata RB in chef?

A file named metadata. rb is located at the top of every cookbook directory structure. The contents of the metadata. rb file provides hints to the Chef server to help ensure that cookbooks are deployed to each node correctly.


2 Answers

In this case, the problem is with the chef.run_list in your Vagrantfile - it instructs Chef to load the "default" recipe from the "berkshelf-test" cookbook. If you're using the git cookbook for testing, you probably want "recipe[git::default]" instead.

You may also need to add require 'berkshelf/vagrant' to the top of your Vagrantfile. See the "Vagrant With Berkshelf" section on the Berkshelf homepage for some more explanation.

like image 124
zts Avatar answered Oct 09 '22 22:10

zts


I was getting this error and the root cause was an issue with how the plugin deals with shared folders. The answer in this issue fixed it: Vagrant + Chef: Error in provision "Shared folders that Chef requires are missing on the virtual machine."

rm .vagrant/machines/default/virtualbox/synced_folders
vagrant reload --provision
like image 27
Nathan Buesgens Avatar answered Oct 09 '22 22:10

Nathan Buesgens