5

I'm trying to test a cookbook that depends on three other local cookbooks. My directory structure looks like this:

/cookbooks/
  cookbook_test/
    recipes 
    templates 
    metadata.rb
  cookbook_dep1/
  cookbook_dep2/
  cookbook_dep3/

My metadata file in the cookbook I'm trying to test (cookbook_test) simply has the other three cookbook dependencies mentioned like:

depends cookbook_dep1
depends cookbook_dep2
depends cookbook_dep3

However when running kitchen converge default-ubuntu-1204 I get the following:

[2014-03-03T18:05:13+00:00] ERROR: Cookbook cookbook_devp1 not found. If you're loading cookbook_devp1 from another cookbook, make sure you configure the dependency in your metadata       
[2014-03-03T18:05:13+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)       

The only thing I could find online is that I should be using berkshelf. Is there no other way of referencing local cookbooks with test-kitchen only ?

Holger Just
  • 52,918
  • 14
  • 115
  • 123
georgthebub
  • 407
  • 6
  • 18

1 Answers1

5

You have to put the dependencies into a directory named "cookbooks" (or "site-cookbooks") in the same directory where .kitchen.yml is. Or use Berkshelf or Librarian-Chef.

You could also try to just symlink the parent directory into "./cookbooks", but not sure if that would cause infinite recursion for some command.

tmatilai
  • 4,071
  • 20
  • 24
  • I don't see how that would work. According to opscode, a main repository should act as a container for all cookbooks, roles, databags and environment code. https://github.com/opscode/chef-repo explains this better. All my cookbooks are contained in a single repository that follows the structure defined by opscode. You're suggesting to put the .kitchen.yml file in the base of the repository and write a different kitchen suite for each type of converge I need to run (= additional kitchen.yml suite with it's own run list)? – georgthebub Mar 04 '14 at 15:03
  • The trend in a couple of years has been towards handling cookbooks as separate software project and repositories. Even Chef (formerly Opscode) has split their monolithic [cookbooks repo](https://github.com/opscode/cookbooks) to [separate ones](https://github.com/opscode-cookbooks) long ago. The "Chef repo" nowadays contains only roles etc, if even that. YMMV, but the general idea of test-kitchen is to help integration testing of *one* cookbook at a time, and use some dependency manager to fetch the other cookbooks. – tmatilai Mar 05 '14 at 07:25
  • It looks like we might have to refactor our project structure. Thank you. – georgthebub Mar 05 '14 at 13:35
  • Where are are roles and environments stored? A separate repository just for that? I can't seem to find it on the opscode org. – georgthebub Mar 05 '14 at 14:13
  • Yeah, you still need a separate "chef-repo" for those. Although some people go as far as implementing also roles and environments with cookbooks and put data bad data into cookbook attributes. YMMV. – tmatilai Mar 05 '14 at 20:37