Salty-Vagrant with VMWare
Although VirtualBox is great for a freebie - I've had many issues with it in the last few years 1. My employer kindly bought me a copy of VMWare and a license for the Vagrant VMWare plugin.
To get started with VMWare, you first need to add the provider and install your license:
$ vagrant plugin install vagrant-vmware-fusion $ vagrant plugin license vagrant-vmware-fusion license.lic
The salty-vagrant plugin is now a part of Vagrant2 as of version 1.3, so no further plugins are required.
Get a box
Next up you'll need an image for VMWare. Hashicorp provide one over here which is for 64-bit Ubuntu 12.04 LTS.
$ vagrant box add precise64 ~/Downloads/precise64_vmware_fusion.box
Vagrant will unpack the box into your home directory, so you can delete the original box file and save space. As you can see, I already had a VirtualBox box named "precise64" on my system:
$ vagrant box list precise64 (virtualbox) precise64 (vmware_fusion) $ $ du -h ~/.vagrant.d/boxes 306M /Users/mafro/.vagrant.d/boxes/precise64/virtualbox 1.2G /Users/mafro/.vagrant.d/boxes/precise64/vmware_fusion 1.5G /Users/mafro/.vagrant.d/boxes/precise64 1.5G /Users/mafro/.vagrant.d/boxes
Allow Vagrant to create you a baseline
$ vagrant init precise64
Minor config adjustments
In order to get Salt working on our new VM, we need to make a couple of mods to the config after the initial creation. The config below does the following things:
- Map our VM to the preconfigured box
- Create a synced folder on the VM which points to all my salt config for the project
- Create a bridged network connection
- Ensure highstate is run on the new minion
Here's a basic
Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.synced_folder "..", "/srv/salt" config.vm.network :public_network config.vm.provision :salt do |salt| salt.minion_config = "salt-minion.conf" salt.run_highstate = true end end
And a basic
salt-minion.conf to drop into the same directory:
file_client: local mysql.user: root mysql.pass: '' grains: role: dev file_roots: base: - /srv/salt/salt/ pillar_roots: base: - /srv/salt/pillar/
Create a VM
$ vagrant up --provider=vmware_fusion Bringing machine 'default' up with 'vmware_fusion' provider... [default] Cloning VMware VM: 'precise64'. This can take some time... [default] Verifying vmnet devices are healthy... [default] Preparing network adapters... [default] Starting the VMware VM... [default] Waiting for the VM to finish booting... [default] The machine is booted and ready! [default] Forwarding ports... [default] -- 22 => 2222 [default] Configuring network adapters within the VM... [default] Enabling and configuring shared folders... [default] -- /Users/mafro/Development/salt: /srv/salt [default] Running provisioner: salt... Copying salt minion config to vm. Checking if salt-minion is installed salt-minion was not found. Checking if salt-call is installed salt-call was not found. Bootstrapping Salt... (this may take a while) Salt successfully configured and installed! run_highstate set to false. Not running state.highstate.
~/.vagrant.d/ and this directory (and indeed any that host a Vagrant VM) we have a lot of disk taken up by hidden files.
$ du -h .vagrant 0B .vagrant/machines/default/virtualbox 4.0K .vagrant/machines/default/vmware_fusion/vm.vmwarevm/564d9e01-c241-0ec7-9c98-833791c0685f.vmem.lck 4.0K .vagrant/machines/default/vmware_fusion/vm.vmwarevm/Virtual Disk.vmdk.lck 2.6G .vagrant/machines/default/vmware_fusion/vm.vmwarevm 2.6G .vagrant/machines/default/vmware_fusion 2.6G .vagrant/machines/default 2.6G .vagrant/machines 2.6G .vagrant
What if something goes wrong
A simple ENV variable will get Vagrant spewing debug, so if anything goes awry, try this:
VAGRANT_LOG=debug vagrant up --provider=vmware_fusion
Sometimes the VBoxHeadless process would max CPU and had to be forcibly killed. Sometimes a suspended VM would refuse to come back up, and I'd have to force stop it and boot from scratch. Neither is the end of the world, but you get what you pay for. ↩
Tagged in devops