I'm new to chef and ran into problems with berkshelf and chef-client. I want to have my own cookbook with dependencies and apply it. My initial cookbook looks like this:
.
├── Berksfile
├── Berksfile.lock
├── chefignore
├── client.rb
├── Gemfile
├── Gemfile.lock
├── metadata.rb
├── README.md
└── recipes
└── default.rb
#./Berksfile
source 'https://supermarket.getchef.com'
metadata
cookbook 'znc'
#./client.rb
cookbook_path '~/.berkshelf/cookbooks'
and when I run sudo bundle exec chef-client -z -o znc --config=client.rb
the chef-client cannot find the cookbook:
Starting Chef Client, version 11.16.4
[2014-10-25T15:34:59+02:00] WARN: Run List override has been provided.
[2014-10-25T15:34:59+02:00] WARN: Original Run List: []
[2014-10-25T15:34:59+02:00] WARN: Overridden Run List: [recipe[znc]]
resolving cookbooks for run list: ["znc"]
================================================================================
Error Resolving Cookbooks for Run List:
================================================================================
Missing Cookbooks:
------------------
No such cookbook: znc
Expanded Run List:
------------------
* znc
Running handlers:
[2014-10-25T15:34:59+02:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-25T15:34:59+02:00] ERROR: Exception handlers complete
[2014-10-25T15:34:59+02:00] FATAL: Stacktrace dumped to /home/sebastian/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.474758165 seconds
[2014-10-25T15:34:59+02:00] ERROR: 412 "Precondition Failed "
[2014-10-25T15:34:59+02:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
also note:
ls ~/.berkshelf/cookbooks
build-essential-2.1.2 znc-0.0.1
Any suggestions why the cookbooks cannot be found?
EDIT:
Thanks for the quick answer. The solution was as John Bellone said to bundle exec berks vendor
and change my client.rb
configuration to:
# ./client.rb
cookbook_path File.dirname(File.expand_path(__FILE__)) + '/berks-cookbooks'
$CWD/cookbooks
. I was getting the sameNo such cookbook
error but for different reason than the question here. I had a typo in the folder name. It wascookbook
in singular instead of plural! (embarrassing) – Hukill