red888
red888

Reputation: 31550

How do I use roles in test kitchen?

I can't figure out how to run roles in a run list in test kitchen.

I did a knife download roles to my chef repo (C:\.chef\roles).

I also did a knife download cookbooks to c:\.chef\cookbooks

Here is the .kitchen.yml for a cookbook I want to test which I plan to run with a particular role (C:\.chef\cookbooks\mybook\.kitchen.yml):

---
driver:
  name: hyperv
  parent_vhd_folder: c:\HyperV\VHDs\
  parent_vhd_name: 2012R2_Fresh_Gen1.vhdx
  vm_switch: NAT
  memory_startup_bytes: 2GB

provisioner:
  name: chef_zero
  roles_path: c:\.chef\roles

transport:
  password: pass123

platforms:
  - name: windows-2012r2

suites:
  - name: default
    run_list:
      - role[myrole]
    attributes:

When I run a kitchen converge I get "No such cookbook:" error for cookbooks that are in that role.

How do I get test kitchen to find those cookbooks? I tried adding a - cookbooks line to my .kitchen.yml with the path of all the necessary cookbooks I have on my workstation, but this did not work- I also think I should be doing this with berkshelf instead?

Upvotes: 2

Views: 2236

Answers (1)

coderanger
coderanger

Reputation: 54211

You'll need to tell Test Kitchen where to get your cookbooks. The easiest way to do this is Berkshelf (or maybe a Policyfile). Put a Berksfile next to the Kitchen config and show it where to get all the cookbooks (supermarket, local paths, chef server, etc).

Upvotes: 1

Related Questions