Unable to configure non-latest chef-dk install

87 Views Asked by At

Our organization has not upgraded to Chef 13 or 14, so we have to pin all our cookbooks to version 12. This means pinning to chef-dk version 1.6.11. I'm spinning a centos7 vm in Vagrant with a cookbook and have set the version, but it will only install the Latest of chefdk, which results in the machine getting Chef 14. I've added a dependency in metadata.rb of chef_version ~> 12, so the provision fails, as Chef 14 is installed but the cookbook demands 12.

I should mention that the VM is for cookbook dev, so i want the right version of chef on it.

What am i missing to get the right version installed?

Thanks.

recipes/default.rb: node.default['chef_dk']['version'] = '1.6.11' node.default['chef_dk']['global_shell_init'] = true include_recipe 'chef-dk'

metadata.rb: depends 'chef-dk' chef_version '~> 12.0'

berksfile: cookbook 'chef-dk'

1

There are 1 best solutions below

5
On

The part that is failing is the "outer" Chef, the thing running the recipe, not the ChefDK install (it never gets that far). We don't generally recommend using Chef to install ChefDK because installing both the chef-client and ChefDK installers on the same machine can lead to confusion as there are overlapping command line tools. I would provision the dev VM using a simpler system, probably a bash script or similar. We also do provide chef/chefdk Docker images on Hub for this kind of thing. (also we don't recommend doing cookbook development inside a VM at all, but I would guess that ship has sailed for you)