How to specify cookbook path in .kitchen.yml file?

2019-02-12 00:03发布

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?

3条回答
不美不萌又怎样
2楼-- · 2019-02-12 00:34

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')

查看更多
时光不老,我们不散
3楼-- · 2019-02-12 00:37

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).

查看更多
虎瘦雄心在
4楼-- · 2019-02-12 00:43

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
查看更多
登录 后发表回答