Using Salt Stack and Vagrant for Drupal Development
Get the Base Box
Get the base box from http://vagrantbox.es. You'll need a box in which to create and run your environment. Boxes are what Vagrant uses for your virtual machines, and they are simply virtual machines that have been configured specifically with Vagrant support. You can create your own from scratch, but it is much quicker and easier just to download a pre-made one that has all of the necessary Vagrant configurations already set up. I used the precise64 box. This is an Ubuntu 12.04 64-bit Linux server with the necessary Vagrant tools and guest additions already in place. You're downloading an entire operating system, so be patient, because it might take a little while. It usually is best to download your box and then save it locally somewhere so you can use it again.
If you're using a 32-bit host operating system, you should instead download the 32-bit version.
Import the Box
Hopefully by this point, you have everything you need. Let's use the command line to interact with Vagrant and import your new box.
To import your box, use:
vagrant box add precise64 /path/to/your/downloaded/box
Relative path names don't work well here, so if you
downloaded your box to your home directory, you need to type out the
full path—for example,
should be typed out like this:
vagrant box add command creates a copy of your box and stores it so
that Vagrant can access it. This box is used to create the instantiation
of the particular box you happen to be using. The nice part is that you
always can press the "reset" button by using
destroy to delete
anything you've done and set it back to its original state before you
started. I go into that in more detail a little later.
Launch the Box and Verify the Guest Additions
Now, launch your box just to make sure that the VirtualBox guest additions are up to date. If they aren't, Salty-Vagrant may not work properly.
Where you store your Vagrant configurations is entirely up to you. I like to keep mine in my home directory under a vagrant folder, just so I can keep track of the different environments I have.
Create a new directory called salty-vagrant and
cd into that directory.
vagrant init to initialize a Vagrantfile there. This is
a standard Vagrant configuration file that is well documented. You
won't need to change any of the configurations, except for line 10:
config.vm.box = "base"
If you followed the quick-start instructions from http://www.vagrantup.com, Vagrant specifies your default boxes as base. Change this to the name of the box you imported, precise64:
config.vm.box = "precise64"
Notice that I left the .box extension off.
Now that your Vagrantfile points to the correct box, use
to start your virtual machine.
If you get a warning that your guest additions are out of date, and it is quite likely that you will if you just installed VirtualBox, proceed to the next step. If you didn't, you can skip to the section "Add a Salty-Vagrant Vagrantfile".
Updating the Guest Additions
If you do need to update the guest additions installed on your box, in this section, I explain how to do it on the Ubuntu-based box you just downloaded. This will be one of the few times that your changes will be permanent within a box. And this time, you want them to be. The guest additions allow your host operating system to interact with the guest operating system. This includes sharing files and network resources between them. You store your configuration files on your host operating system, and then they are copied to the guest operating system when you start it up each time, so it is important that the shared-folder functionality works.
After Vagrant finishes booting the guest operating
system, you'll need to connect to this box using
the Vagrant-supplied command:
You then will be logged in to the guest operating system as the "vagrant" user.
Updating the guest additions probably is the trickiest and most-involved task. If you run into any problems, lots of resources are available on-line. Most distributions mention a number of solutions in their respective forums, and the VirtualBox Manual (https://www.virtualbox.org/manual/ch04.html) also has some detailed information. I'm going to show you how to download and update the virtualbox guest additions from virtualbox.org, and update them on the precise64 box that you just downloaded as an example.
First, you need some packages to build and compile the Linux kernel. Use Ubuntu's package manager, apt, to install them:
sudo apt-get install dkms linux-headers-3.2.0-23-generic
If you're using a non-Debian machine, search for the proper names in your particular package manager and use the header version that matches your particular kernel.
With kernel support now in place, browse to http://download.virtualbox.org/virtualbox and locate the folder that matches the version of VirtualBox that you have installed. Generally, you can find what version you have through the VirtualBox graphical interface or the warning message generated by Vagrant when you booted your virtual machine. Now, locate the VBoxGuestAdditions_x.x.x.iso that also matches the version of Virtualbox that you have installed. Replace the x in the filename with the specific version for your version of VirtualBox.
You can copy the URL to this file and paste it into the terminal window of your guest Ubuntu system that you had previously SSH'd into. Use wget to download the ISO:
wget http://download.virtualbox.org/virtualbox/x.x.x/ ↪VBoxGuestAdditions_x.x.x.iso
Again, replace the x in the filename with the version that matches your VirtualBox installation.
You now should have an .iso file in your home directory.
After it's downloaded, mount it so that you can access the files contained in it by first creating a temporary directory in which to mount this .iso. Within your home directory, use this command:
mkdir -p tmp/vbox
Now, mount the .iso into that folder:
sudo mount -o loop VBoxGuestAdditions_x.x.x.iso tmp/vbox/
Within the .iso, you'll find a VBoxLinuxAdditions.run script. Copy this to your home directory:
cp VBoxLinuxAdditions.run ~
Now, make it executable by adding the execute flag:
chmod +x VBoxLinuxAdditions.run
And finally, run the installation script:
If you get a warning about failing to install the window system drivers,
you safely can ignore it. The box you are installing these guest additions
on is a server and doesn't have a window manager installed. You
also can use the
--nox11 flag like this when you install the updated
sudo ./VBoxLinuxAdditions.run --nox11
The last step in this installation is to reboot the machine to ensure that the guest additions are up to date with:
After the box restarts, log back in with:
Now you can unmount the .iso using
sudo umount /mnt, if it isn't
already, and delete the VBoxLinuxAdditions.run and the .iso file to
save space. You also optionally can do some housekeeping by deleting the
Ben Hosmer is a DEVOP with RadiantBlue Technologies where he develops and maintains Drupal sites and administers various servers. He is an open-source advocate and helps spread the use of Linux and other open-source software within the US government.
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide
- Papa's Got a Brand New NAS
- Applied Expert Systems, Inc.'s CleverView for TCP/IP on Linux
- Panther MPC, Inc.'s Panther Alpha
- Simplenote, Simply Awesome!
- GENIVI Alliance's GENIVI Vehicle Simulator
- The Tiny Internet Project, Part III
- Rogue Wave Software's TotalView for HPC and CodeDynamics
- NethServer: Linux without All That Linux Stuff
- Jetico's BestCrypt Container Encryption for Linux
- Sometimes My Office Goes with Me