How to specify cookbook path in .kitchen.yml file?
Asked Answered
C

3

17

I have my Chef cookbooks stored in chef/cookbooks/ folder. When running kitchen converge I am still getting notice

Berksfile, Cheffile, cookbooks/, or metadata.rb not found so Chef will run with effectively no cookbooks. Is this intended?

I tried many options, for example:

suites:
  - name: default
    run_list: recipe[git]
    cookbook_path: "chef/cookbooks"

but I can't find the proper solution. How to specify the cookbooks' and roles' paths?

Crankcase answered 29/4, 2014 at 14:40 Comment(4)
Are you running test-kitchen within the folder of a cookbook or in your repo containing multiple cookbooks? Should be the first one..Annuity
It's the latter. My goal is to test all the cookbooks together. I mean to make sure the node was provisioned well and everything is up and running. I don't need to test one cookbook (because I use the community ones anyway). Is that a wrong approach?Crankcase
Yes, to my knowledge, t-k is for testing one particular cookbook (that can depend on others).Annuity
Ok, is there any other sophisticated approach to test the whole infrastructure? Or the admins usually simply "believe" it all works together if the parts do?Crankcase
U
16

You'll want to put the path in your berksfile, which will likely end up looking like so..

source 'https://supermarket.chef.io'
cookbook 'cookbookname', path: 'relative/or/absolute/path/to/cookbook/directory'

The berksfile is also used by chef when you deploy your code so it helps if your relative file structure is the same on your machine as it is on your chef server (i.e. all cookbooks share a directory so your berksfile can use the path '../cookbookname')

Upswell answered 28/7, 2015 at 18:23 Comment(1)
This solved the problem for me. I was running .kitchen.yml from a directory outside of my cookbook in another project, with references pointing back to values inside the cookbook.Codicil
M
3

You want to set it in the provisioner section:

provisioner:
  name: chef_zero
  require_chef_omnibus: 11.12.2
  cookbook_path: whatever/path/to/cookbooks
Murther answered 29/4, 2014 at 20:52 Comment(7)
Still can't get it work, do u have a minute to have a fast look into my bash log? gist.github.com/tsusanka/8cdf9c7828a85cd94889 the think is the files aren't even copied to the OSCrankcase
It looks like you are already using Berkshelf - why use a cookbook_path at all?Murther
Thx for the reply. I decided to version the cookbooks downloaded via Berkshelf. I guess that's unnecessary, but anyway even if I use Berkshelf, I still have my own non-community cookbooks located in chef/cookbooks which I need to be added.Crankcase
If you are using Berkshelf why not just put it in there. Add a line like this to your Berksfile: cookbook 'name', path: '/local/path/to/cookbook'Pacific
@Pacific he would need to do that with each oneMurther
@Murther you are correct. I guess the only other easy option is to change the Berkshelf cookbook location or do what we do and set up a berkshelf-api server.Pacific
Late to the party, hope this might help someone, using chef dk 2.6.2+ and chef-client 13.12.3 can use ------------------ provisioner: name: chef_zero product_name: chef product_version: 12.22.3Brancusi
I
1

Set up a top level Berksfile where you have .kitchen.yml that contains a reference to the cookbooks you're testing. Each cookbook will declare their dependencies and berks install at the top level will ensure you have everything installed.

(I just ran into the same issue starting out with chefdk 0.4).

Ieyasu answered 5/2, 2015 at 23:13 Comment(1)
I had this problem, where the berkshelf provisioning wouldn't happen when trying to run test kitchen. This was the solution, so commenting about that here, to help others find the same solution.Multiversity

© 2022 - 2024 — McMap. All rights reserved.