Better Local Development with Vagrant


Published on

Watch the presentation at

At Mediacurrent, we found that on-ramping new team members to a project was costing us a lot of time (and money). Although some of our developers already used Vagrant for development, most of us used (native) MAMP or native LAMP, and we routinely spent time troubleshooting problems with our local stack or site-issues that only occurred on one of our machines. Additionally, sometimes errors would appear in Production that could not be reproduced in our local environments.

Vagrant solves a lot of those headaches. By automating the generation of a LAMP stack and project setup - from host file edits to site installations to database imports - we can be assured that we're all working from identical environments. Additionally, we have fewer "surprises" when we release to production, because our Vagrant stack has been tuned to closely match that environment.

Other benefits include:
- A clean separation between projects (e.g., no more switching PHP versions for the project de l'heure).
- Low-cost troubleshooting: if your local stack gets foobared, you can wipe away and rebuild for a fresh start.

If you are already familiar with Vagrant, this presentation will help you learn about latest projects in the Drupal Vagrant ecosystem that will improve your workflow.

For those new to Vagrant, watch this presentation to learn about why you should be using it and how to get started!

Note: This webinar reviews some of the active Vagrant projects in the Drupal community; the proposed solutions are being explored but are not expressly endorsed by Mediacurrent.

Published in: Technology, Self Improvement

Better Local Development with Vagrant

  1. 1. Better Local Development with Vagrant by Derek DeRaps Mediacurrent Webinar November 19th, 2013
  2. 2. Derek DeRaps Drupal Developer d.o derek.deraps @mediacurrent
  3. 3. @Mediacurrent Agenda ● ● ● ● ● ● What is Vagrant? Why use it? (BENEFITS) Why not to use it? (DOWNSIDES) Approaches (Per-project vs. One stack) Provisioners (Chef and Puppet) Demos! ○ Proviso ○ Drupal LAMP ○ Kalabox (ask me for a code) ● Q&A, Discussion
  4. 4. What is Vagrant?
  5. 5. @Mediacurrent What is Vagrant? Vagrant is a tool for building complete development environments. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases development/production parity, and makes the "works on my machine" excuse a relic of the past.
  6. 6. @Mediacurrent What is Vagrant? ● a headless* Virtual Machine. ○ VirtualBox (free) ○ VMWare Fusion (paid) ○ Parallels (yup, see here) ● a Development Environment** ○ LAMP stack ○ WWW files mounted for host access ○ Replaces your local stack: MAMP, WAMP, XAMPP, etc. ● Automated stack provisioning + configuration ○ via Chef, Puppet, or ?
  7. 7. Why use it? Benefits
  8. 8. @Mediacurrent Benefits ● On-ramp new team members more quickly and more easily. ● Sandbox environment - clean local machine. ● Automated provisioning and configuration ○ Chef, Puppet, Others? ● Mirror the production stack and configuration. ● Same stack across your team. ● Lowers the cost of mistakes. Boxes are “cheap” - easy to blow away + recreate.
  9. 9. Why not to use it? Disadvantages
  10. 10. @Mediacurrent Disadvantages Fresh build takes a long time (5 to 10 minutes). Disk space/bloat, when using boxes per project. Learning curve: Chef/Puppet, etc. Large upfront investment to configure. ○ New Vagrant projects lowering this cost. ● Slow file system? ○ Mount with NFS. ● Need drush access? ○ Use Drush Aliases to access the guest. ● ● ● ●
  11. 11. Directory Layout & Approaches
  12. 12. @Mediacurrent Directory Layout
  13. 13. @Mediacurrent Approaches ● One box ○ All your projects in one box. ○ 70% of the “win” with 50% of the work. ● Boxes per hosting environment ○ All your Acquia clients in one Vagrant tuned to match Acquia’s stack, et al for each different production hosting environment. ● Per-project boxes ○ Tuned to exactly match project’s prod. env. ○ More overhead when switching contexts.
  14. 14. Puppet and Chef Provisioners
  15. 15. @Mediacurrent Provisioners ● Puppet ○ Some folks love it >Chef. ● Chef (by OpsCode) ○ Create recipes inside of cookbooks to provision and configure the stack. ○ Everything you need for a basic LAMP stack provided by OpsCode: https://github. com/opscode/cookbooks ● A quick tour of Chef recipes and cookbooks.
  16. 16. Time for some Demos :) “ How do I Vagrant?? ”
  17. 17. @Mediacurrent Kalabox ● ● ● ● ● ● Node.js application wrapper for a single box. Still in private beta - Ask me for a beta key so you can download and try it out. The most win for your time - dead simple to install and use! Even more WIN if you host with Pantheon. Warning: last beta install wiped out my VirtualBox installation (but not the box files!) and I had to reinstall. Poke around in ~/.kalabox
  18. 18. @Mediacurrent Proviso ● ● ● ● Watch the DrupalConPrague session Drupal-specific: Aiming to be *THE* development environment for Drupalers. A collaboration between different agencies who have all built Vagrant profiles from the ground-up multiple times, and are sick of it. A lofty goal, given the variance between hosting environments. Still very much a work in progress: Last I used, did not come with a working stack.
  19. 19. @Mediacurrent Drupal LAMP A project by New Media (a Denver agency) A single environment for all their projects. Heavy investment in project automation. Can automatically download the project repository, import the site’s database, update your host file, and more. ● They are Chef masters: All their configuration (including production boxes) managed by Chef server. ● ● ● ●
  20. 20. Thank You! Questions? @Mediacurent user derek.deraps