Vagrant Your Drupal
In one of my recent posts, I described how I used VMWare to create a Drupal I could play with before deploying updates to morevaadin.com. Then, at Devoxx France, I attended a session where the talker detailed how he set up a whole infrastructure for after work formations with Vagrant. Meanwhile, a little turn of fate put me in charge of some Drupal projects and I had to get better at it... fast. I got my hands on the Definitive Guide to Drupal 7 that talks about Drupal use with Vagrant. This was definitely too much: I decided to take on this opportunity to automatically manage my own Drupal infrastructure. These are the steps I followed and the lessons I learned. Note my host OS is Windows 7 :-)
Oracle's VirtualBox is the format used by Vagrant. Go on their download page and choose your pick.
Vagrant download page is here. Once installed on your system, you should put the bin directory on your PATH. Now, get the Ubuntu Lucyd Linx box ready with:
vagrant box add base http://files.vagrantup.com/lucid32.box
This download the box in your %USER_HOME%/.vagrant.d/boxes under the lucid32 folder (at least on Windows).
Get Drupal Vagrant project
Download the current version of Drupal Vagrant and extract it in the directory of your choice. Edit the Vagrantfile according to the following guidelines:
config.vm.box = "lucid32" // References the right box ... config.vm.network :hostonly, "220.127.116.11" // Creates a machine with this IP
Then, boot the virtual box with vagrant up and let Vagrant take care of all things (boot the VM, get the necessary applications, configure all, etc.). Update your etc/hosts file to have the 2 following domains pointing to 18.104.22.168. [text]22.214.171.124 drupal.vbox.local 126.96.36.199 dev-site.vbox.local[/text] At the end of the process (it could be a lenghty one), browsing on your host system to http://drupal.vbox.local/install.php should get you the familiar Drupal installation screen. You're on!
SSH into the virtual box
Now is time to get into the host system, with vagrant ssh. If on Windows, here comes the hard part. Since there's no SSH utility out-of-the-box, you have to get one. Personally, I used PuTTY. Not the VM uses a SSH key for authentication and unfortunately, the format of Vagrant's provided key is not compatible with PuTTY so that we have to use PuTTYGen to translate %USER_HOME%/.vagrant.d/insecure_private_key into a format PuTTY is able to use. When done, connect with PuTTY on the system (finally).
Note: I recently stumbled upon this other Drupal cookbook but it cannot be used as is. Better DevOps than me can probably fix it.