0
votes

We have recently started implementing a proper CI-based build pipeline for continuous deployment scenario and decided to use Chef as our CM tool. We also use Vagrant for creating isolated local dev environments for our devs, since it allows a simple 'vagrant up' and the env just runs. Vagrant is supposed to support Chef Zero, which it does. However, that requires holding predownloaded cookbooks in a 'cookbooks' dir, meaning managing dependencies and their versions would be a huge pain without a "packet manager".

What I would like to do is to use either a Policyfile or a Berksfile to manage the cookbook dependencies. Unfortunatelly, this does not work (or I am doing something wrong). First of all, I could not find a way to implement the Policyfile using Vagrant, even though the feature was released 2 years ago. The only thing that popped up was this. The Berkshelf way was more promising, because there is a 'vagrant-berkshelf' plugin for Vagrant, which does exactly what I want...but with a few hiccups. One of the issues is the dependency on ChefDK. The main one, however, is that it's been sort of deprecated in favour of the TestKitchen.

So, TestKitchen, there's been a lot of fuss about this neat tool. It supports both Policyfiles and Berkshelf, it has a Vagrant provider that runs the VM using Vagrant. So what is wrong? To my understanding Chef's TestKitchen was intended for Cookbook developers, because it allows automated local Cookbook testing, etc. But what about other devs? For example if a dev only works on the project (app) itself, and not the infrastructure, why would the dev even need ChefDK? All the dev wants to do is download the source code for the app (web app in our case), which includes Vagrantfile in the root dir, then simply type 'vagrant up' (because VirtualBox and Vagrant are already installed on the machine) and start working!

Yes, it is possible to use the TestKitchen as a Vagrant wrapper (this guy says it's fine). Instead of the 'vagrant up', the dev would type 'kitchen converge' and then start working. But that implies the dev already installed ChefDK, alongside the VirtualBox and Vagrant.

Is there any [good and modern] way of not using the TestKitchen as a development environment provider? Or is it not considered a bad practice? To me, it seems wierd that the dev has to install ChefDK if he wants to spin the dev env on his laptop. How do you have your dev environment set up?

2
Why would it be less good to install chefdk than vagrant and a bunch of plugins to support chef as vagrant provisionner ? This question is probably highly opinion based and so not a good fit for StackOverflow.Tensibai
Tensibai well..all I can now is just hope it won't get downvoted =) Thanks for your input though!simon
Well, the question is clear for me, would probably be useful on another media (maybe on the mailing list discourse.chef.io ). so there's no reason to downvote it, I did vote to close it as opinion based, but I don't think it worth a downvote.Tensibai
I think you do not need the whole chefDK, just install test-kitchen as rubygem on its own.Draco Ater

2 Answers

1
votes

We use Jankins to update cookbooks on the chef-server. Also, we use Berkshelf to control cookbook dependencies.

Vagrant can provision machine using chef-client. It connects to the chef-server gets the latest cookbooks/environments/roles and provisions the machine.

It works, but it takes a lot of time to provision vagrant-machine. So it works for now but we are looking for some better options.

chef-zero can be used for debugging (but it is better to use test kitchen) and I think it is not suitable for the workflow you want.

Also, you can check these vagrant plugins, they're really helpful: vagrant-omnibus, vagrant-cachier, vagrant-vbguest, vagrant-hostsupdater, vagrant-notify

0
votes

The policyfile workflow was built expecting the use of Chef Server and chef-client. As such you would generally use it via the chef_client provisioner in Vagrant. This is probably not going to be the workflow you want though. It would be possible to build something which uses the policy export system and some fancy file trickery to make a Berks-like Vagrant plugin but you would have to do that yourself.

Most of the Chef world has stopped using Vagrant for setting up development environments in favor of cloud systems as making something "like production" in a VBox VM is generally not a possible as you might think.