dharam
dharam

Reputation: 8096

Cookbook not found : Chef Solo

I downloaded the cookbook "oc-java-master" from the Chef community and now I am trying to run it using chef-solo which i have installed on a Windows Server 2008.

After a lot of googling and stackoverflow support i was able to get the JSON file picked up which defines the run lists. But the below error has been troubling me for last 4-5 hours and I am totally clueless.

[2012-11-28T11:33:28+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook java not found. If you're loading java from another cookbook, make sure you configure the dependency in your metadata

If anyone can look at the cookbook and suggest me some solution I will be grateful to you. The URL of the cookbook is here.

Upvotes: 4

Views: 14731

Answers (5)

Brandon Hawbaker
Brandon Hawbaker

Reputation: 338

I had almost the exact same issue although my resolution was something else in addition to what you see above. In my case, I had manually copied the cookbooks from a box where the ChefDK was installed. I had copied the cookbooks from the

c:\users[user].berkshelf\cookbooks directory

to the target machine where I intended to run the chef-client. I originally tried running chef-zero with problems, so I tried chef-solo and setup a .json file with the run list and a solo.rb file to pass like you see above, but was still getting the error.

It turns out the issue was caused by each copied cookbook having the version embedded in the name. After removing the version from the names, it then found the exact versions from the path specified in the solo.rb.

In my case the problem wasn't finding the cookbooks, it was finding the cookbooks with the exact same name as specified in dependencies (without the version).

Upvotes: 0

Farrukh Najmi
Farrukh Najmi

Reputation: 5316

In my case I was using Vagrant with chef_solo provider. It appears that the folder /tmp/vagrant-chef/a0544031e745d8ec23aa205c03bf9231 on the target chef node (in my case a Vagrant managed VM)is where this provider caches cookbooks. This folder was empty for some reason causing chef_solo to not find any cookbooks. Perhaps it was empty because I interrupted an execution (Only a guess).

I deleted /tmp/vagrant-chef entirely and then did "vagran reoad" followed by "vagrant provision" command. This created a new copy of the /tmp/vagrant-chef/a0544031e745d8ec23aa205c03bf9231/cookbooks tree and this time everything worked just fine and I no longer got "Cookbook not found"

Upvotes: 2

anish
anish

Reputation: 7412

  1. Chef expects a configuration file, but will accept options on the command line, in lieu of a configuration file.
  2. It expects the configuration file to reside in /etc/chef

or give your own solo.rb file

chef-solo --config ~/.chef/solo.rb --override-runlist 'recipe[your-app]'

where solo.rb has the contents:

cookbook_path ENV['HOME']

Upvotes: 0

Himanshu
Himanshu

Reputation: 31

You need to add one line in metadata.rb file. depends "cookbookname" for your issue goto metadata file of oc-java-master and write

depends "java"

Please verify that cookbook java is present into your cookbook path

Upvotes: 3

jtimberman
jtimberman

Reputation: 8258

A few things.

With Chef Solo, you have to tell it more information up front so it finds the cookbooks.

  1. It needs to know what run list (and node attributes if any) to use for the run. This is the "json file" passed with the -j option.

  2. It needs to know the path to the cookbooks. You can download them from a remote tarball with the -r option, and let it handle the rest, or you have to write a config file with the cookbook_path value and un-archive the cookbooks you want to use in that directory. This is c:\var\chef\cookbooks by default.

Also, the Opscode Chef Community Site is not the same as the "Cookbooks" organization on GitHub.

Opscode's Java cookbook does not work on Windows. You'll need to write your own or find another one that does.

Finally, the Chef mailing lists and IRC channels are the best way to get help with Chef quickly.

Upvotes: 4

Related Questions