A blog

Vagrant, VMware, and Berkshelf

So, Vagrant is a great tool, which costs you nothing to use if you pair it with Virtualbox. Unfortunately, Virtualbox is somewhat less awesome in heavy use. VMware does a better job of things, and Vagrant added support for it with a paid-for plugin. As the first commercial product of Hashicorp (Vagrant’s developer), this is a nice way to say thankyou for Vagrant while getting a better user experience too.

In theory.

While Vagrant generally does a great job of hiding the differences between the various “providers” (virtualisation systems) it supports, some still leak through. I ran into the following problem when running “vagrant provision” to re-run Chef in the guest system after making some changes:

[default] Running provisioner: chef_solo...
Shared folders that Chef requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.

Contrary to the message, vagrant reload didn’t help.1

When I looked at the guest system, I found that the directory that should have contained my Chef cookbooks (managed by Berkshelf) no longer appeared – the mountpoint was still listed, but it no longer worked. Eventually, that lead me to issue #88 on the vagrant-berkshelf repo, which explains the cause – that directory is deleted and recreated on every run, which breaks the “vmware” and “nfs” methods of sharing folders under Vagrant.

In lieu of a proper fix, I bodged one together that relies on rsync being available on your path. If you’re having the same problem and want to give it a try, check out this branch on github.

  1. It turns out that this would have worked on Vagrant releases prior to 1.3.0. After that, vagrant reload --provision would have worked. In both cases, this workaround is very slow as it restarts the VM.