I DevOps

and this is what I think about it

Test Kitchen with vagrant and vSphere

Test kitchen, a popular tool whose job is to run integration tests on chef cookbooks, normally spins up VMs on Virtualbox, but what about your massive vSphere cluster?.  That’s the question I asked myself.

Kitchen already has a pretty awesome plugin for connecting to vSphere called kitchen vsphere. However, I love vagrant and I wanted to see if I could keep using vagrant instead so that I didn’t have to change up my .kitchen.yml too much.

What I learned: It’s pretty easy. This is also a pretty hacked out solution that is somewhat janky… but it works for now.

  1. Install the vagrant-vsphere plugin
  2. Create a Vagrantfile from the examples on GitHub and make sure it works with plain old vagrant up
  3. Rename/symlink the Vagrant file to be Vagrantfile.rb (silly file extension restrictions in ruby)
  4. Add the following to the driver section of your .kitchen.yml underneath where it says driver: vagrant
vagrantfiles:
 - ~/path/to/your/example/Vagrantfile.rb

And now run kitchen test with a default provider env var “VAGRANT_DEFAULT_PROVIDER=vsphere kitchen test”

 

You are limited to only 1 OS platform in your “platforms” section of your kitchen.yml which is also pretty useless as the platform is actually decisded by what template you are cloning in vSphere… unless you somehow make the vSphere template in parameterized to the platform name