Search code examples
chef-infrachef-soloberkshelf

Migration to Berkshelf


I am currently in the process of migrating our organization's kitchen to Berkshelf.

SETUP

We use git submodules to maintain the vendor cookbooks in the cookbooks dir. our custom cookbooks are in site-cookbooks.

I got rid of all the submodules in cookbooks dir and created a Berksfile with our custom cookbooks. I have set ENV['BERKSHELF_PATH'] in Berksfile to cookbooks dir so as to contain the vendor cookbooks in one place and added cookbooks dir to .gitignore.

When I execute Berks install the vendor cookbooks are installed in cookbooks dir as cookbook_name-version.

PROBLEM

When I run chef-solo to run the custom cookbooks, chef run fails as the recipes in vendor cookbooks which have either template resource or cookbook_file resource fail as chef is unable to find the templates or files in files dir or templates dir of the cookbook even though they are present.

Renaming the vendor cookbooks from say apt-2.7.0 as installed by berkshelf to just apt without the version number and adding the vendor cookbook to Berksfile as for example cookbook 'apt', path: './cookbooks/apt' solves the problem.

However I honestly think that I am heading in the wrong direction and this should not be the case.


Solution

  • You don't want to set BERKSHELF_PATH, that is the internal tracking directory for Berkshelf and should almost never be touched. Kitchen will automatically handle running berks vendor for you as part of the provisioning process.