I probably got the whole concept wrong: I have a working Vagrant VM with Ubuntu 12.04, on top of it I want to install a few packages and config files. I have them set in Chef, in the path cookbooks/my_project/recipes I have a vagrant-dev.rb file with all the instructions. Now my Vagrant config in Vagrantfile must be the problem here:

config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "cookbooks/my_project/recipes"
    chef.add_recipe "vagrant-dev.rb"

and when I load the VM I get

FATAL: Chef::Exceptions::CookbookNotFound: Cookbook vagrant-dev.rb not found.

I tried without the .rb at the end. I guess it's a completely different matter and I'm not using it the correct way. But after searching I couldn't find anything that explained how to do it properly.


When using chef, all recipes must be in cookbooks. It looks like you might already have it in a cookbook, and are just calling it wrong, but I'll cover all of it, so you can double check.

Cookbooks are literally just a collection of recipe rb files, a bit of metadata, and optionally some other files (like templates, or databags). So you can't include the .rb file directly, you have to reference its cookbook, and then the name of the file (with out .rb) to run it.

A simple cookbook's structure should look like:

    readme.md # needed for the long_description in metadata to work
    metadata.rb # contains the actual information for the cookbook
    recipes # Holds all the cookbook's recipies
        default.rb # This is the default recipe, run if one isn't specified
    templates # Templates that can be called by the cookbook

The name of the main directory doesn't matter, and the templates directory is optional.


name             "SomeCookbook"
maintainer       "Me"
maintainer_email "support@me.com"
license          "None"
description      "Does something cool"
long_description IO.read(File.join(File.dirname(__FILE__), 'readme.md'))
version          "0.0.1"

supports "centos"

Follow the above structure, and make sure to stick your recipe into the recipes folder.
Then add this to your vagrant file:

chef.add_recipe "SomeCookbook::vagrant-dev"

Hope the above clears things up a bit.

  • great answer thanks, I needed to update my cookbooks path to just "cookbooks" in order for it to work but it's ok now the instructions are found and applied!
    – Bastian
    Sep 15 '13 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.