0
votes

Trying to setup a rails app using chef but getting Missing Cookbooks error.

Steps to Reproduce

$ chef generate app chef_rails #create new app that will hold cookbooks for rails.
$ echo "cookbook 'ruby-ng'" >> cookbooks/chef_rails/Berksfile
$ cd cookbooks/chef_rails/
$ berks install
$ berks vendor
$ cd ../../
$ vim .kitchen.yml #add `recipe[ruby-ng::default]` to runlist
$ kitchen converge

Which gives the following error:

Missing Cookbooks: ------------------ No such cookbook: ruby-ng

   Expanded Run List:
   ------------------
   * chef_rails::default
   * ruby-ng::default

For this, I search the existing answers on stackoverflow & figured that if I move vendored cookbooks, chef is able to find them

$ mv cookbooks/chef_rails/berks-cookbooks/* cookbooks
$ ls cookbooks                                                                                        
apt             chef_rails      mingw           ruby-ng         windows
build-essential compat_resource ohai            seven_zip
$ kitchen converge #works flawlessly
$ kitchen list                                                                                       
Instance             Driver   Provisioner  Verifier  Transport  Last Action  Last Error
default-ubuntu-1404  Vagrant  ChefZero     Inspec    Ssh        Converged    <None>

Here are the versions, I am using:

$ chef --version                                                                                      
Chef Development Kit Version: 1.1.16
chef-client version: 12.17.44
delivery version: master (83358fb62c0f711c70ad5a81030a6cae4017f103)
berks version: 5.2.0
kitchen version: 1.14.2

Questions

  1. I am able to fix the error but I don't understand "why" this error occurred.I think this is related to chef_repo_path but don't really understand it. so if can explain or point to relevant docs?
  2. Should I be vendoring the cookbooks into ./cookbooks instead of ./cookbooks/chef_rails/berks-cookbooks/. if yes, then how do I make berks vendor do that?
  3. After development, For uploading to github. should include the vendored cookbooks in the repo as well? Planning to use these cookbooks with Chef Server to setup server for rails.
2

2 Answers

1
votes

So a few issues: first as @StephenKing said you need to have the .kitchen.yml be right next to the Berksfile and then you also need to run the kitchen command from that folder. Second, you don't need (or want) to use berks vendor, as Test Kitchen has its own Berkshelf support that activates automatically when you have a Berksfile in the correct place.

0
votes

The .kitchen.yml file should be placed inside the cookbook directory.