/ CMS, DEVOPS, DRUPAL

Vagrant your Drupal

In one of my recent post, 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 put 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.

My host OS is Windows 7 🙂

Download VirtualBox

Oracle’s VirtualBox is the format used by Vagrant. Go on their download page and choose your pick.

Download Vagrant

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, "33.33.33.10" // 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 33.33.33.10.

33.33.33.10	   drupal.vbox.local
33.33.33.10	   dev-site.vbox.local

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).

Conclusion

All in all, this approach works alright, altough Drush is present in /usr/share/drush but doesn’t seem to work (Git is installed and works fine).

I recently stumbled upon this other Drupal cookbook but it cannot be used as is. Better DevOps than me can probably fix it.

Nicolas Fränkel

Nicolas Fränkel

Developer Advocate with 15+ years experience consulting for many different customers, in a wide range of contexts (such as telecoms, banking, insurances, large retail and public sector). Usually working on Java/Java EE and Spring technologies, but with focused interests like Rich Internet Applications, Testing, CI/CD and DevOps. Also double as a trainer and triples as a book author.

Read More
Vagrant your Drupal
Share this