Chef Provisioning and Berkshelf

I’m trying to us chef provisioning.

It seems that it can’t find my cookbooks. It doesn’t appear to have any knowledge of berkshelf. Running a ‘berks install’ installs dependent cookbooks just fine. However, running chef provisioning with a command like this:

chef-client -z -o some-recipe -c knife.rb

results in an error that the apt cookbook can’t be found. From reading various blogs, it seems like I might need to run a ‘berks vendor somedir’ after each and every edit of the recipe, and then also make sure that the vendored dir is in the cookbook_paths in my knife.rb. Do I really need to run a berks vendor every single time I edit the recipe?

I saw some blogs where people added ~/.berkshelf/cookbooks to their cookbook_paths in knife.rb. However, this won’t work as the cookbooks in the berkshelf cache directory are stored as $name-$version, and chef wants them in the format of just $name.

There’s zero documentation on how chef provisioning is supposed to work with berkshelf as far as I can tell. Btw, is chef provisioning dead? Is it still supported?

Thanks.
Doug

berks vendor is indeed the answer. It will take your main cookbook, and all the cookbooks it depends on (including the ones from berkshelf), and create a tarball of all of them. You untar it on the node, and then point chef zero to it.

Kevin Keane
Whom the IT Pros Call
The NetTech
http://www.4nettech.com
Our values: Privacy, Liberty, Justice
See https://www.4nettech.com/corp/the-nettech-values.html

I have ‘berks vendor cookbooks’ command that grabs all the cookbooks needed. In my knife.rb I have cookbook_path point to this dir. I don’t have to create/unpack tarballs. The cookbooks get transferred to the instance from provisioning node(my laptop) automatically. I have provisioned nodes using chef-zero on the target instance and chef-server. If you are pointing instances at a chef-server you would need to upload the cookbooks to server so that instances could use them. berks vendor will not do that. I have all these commands in a rakefile so I just have to run a single rake command to get the instances I need.

So, berks vendor is the answer I guess. This means I have to run a ‘berks vendor’ command after every edit to the recipe. There’s no better way? I guess there’s no tooling written around this. Test Kitchen doesn’t require me to run a berks vendor. That’s all automated.

Doug

That’s really no different from having to use berks upload after each edit if you are using a chef server, isn’t it?

Test kitchen is a bit of a special case because it doesn’t run on a node somewhere else, but on your chef workstation itself.

Kevin Keane
Whom the IT Pros Call
The NetTech
http://www.4nettech.com
Our values: Privacy, Liberty, Justice
See https://www.4nettech.com/corp/the-nettech-values.html