Cookbook dependencies with Berkshelf


#1

so i have a repo. the repo have multiple cookbooks under /repo/cookbooks/ dir. Now, all the kitchen test works at the cookbook level. I am using these cookbooks/recipes to chef out the node configurations. So, as a test to make sure the combination of all the recipes works at a role level, i am trying to use kitchen,

To do this (not sure if this is the recommended or not, if not please advise), i have created a .kitchen.yml file in the root of the repo. In this file, i have added all the recipes that constitutes the role. And for kitchen to know where these recipes are from, i have added a Berksfile, and added the cookbooks.

e.g.

source 'https://supermarket.chef.io
cookbook ‘chef-client’

#below entries are added to execute the kitchen test for a combination of recipes from this repo’s base
cookbook ‘nginx’, path: 'cookbooks/nginx’
cookbook ‘mytomcat’, path: ‘cookbooks/mytomcat’

The cookbook mytomcat depends on a cookbook called my_java, which is in the same repo. And this is defined in the metadata of the “mytomcat” cookbook.

So, when i run kitchen converge; the below err shows up

→ berks
Resolving cookbook dependencies…
Fetching ‘nginx’ from source at cookbooks/nginx
Fetching ‘mytomcat’ from source at cookbooks/mytomcat
Fetching cookbook index from https://supermarket.chef.io
Unable to satisfy constraints on package my_java, which does not exist, due to solution constraint (mytomcat = 0.1.1). Solution constraints that may result in a constraint on my_java: [(mytomcat = 0.1.1) -> (my_java ~> 0.1.0)]
Missing artifacts: my_java
Demand that cannot be met: (mytomcat = 0.1.1)
Unable to find a solution for demands: chef-client (7.0.2), compat_resource (12.16.2), cron (3.0.0), logrotate (2.1.0), nginx (0.1.1), ohai (4.2.3), windows (2.1.1), yum (4.1.0), yum-epel (2.0.0), mytomcat (0.1.1)

To fix this: i have to make the Berksfile like so:

source 'https://supermarket.chef.io
cookbook ‘chef-client’

#below entries are added to execute the kitchen test for a combination of recipes from this repo’s base
cookbook ‘nginx’, path: 'cookbooks/nginx’
cookbook ‘my_java’, path: 'cookbooks/my_java’
cookbook ‘mytomcat’, path: ‘cookbooks/mytomcat’

Question: why is the berkshelf not able to resolve the dependent cookbook in this case?

Update:
Looks like i am messing up with librarian way and berkshelf.


#2

Sounds like you’ve got it sorted, but basically Berks has no concept of a Chef Repo, and definitely doesn’t have any concept of an implicit Chef Repo. If a cookbook isn’t available from the place you specified in your source, you need to provide a specific place for it to be found.