Vagrant Environment Setup Organization

I’m currently using vagrant for all my development work. Having said that I see that most people seem to be setting up a single box per project. However, I have a single box that is shared across multiple projects. I’m kind of treating the vagrant box as a “remote” dev server where one would very likely have several sites hosted. I’m on a mac and this is my mac directory structure for such a set-up.

~/Workspace/vm/profile/*

Each separate vagrant/puphpet zip file goes under here. So I essentially do this to start up my machine currently.

cd ~/Workspace/vm/profile/[name]
vagrant up

I than have the shared folder located in a separate directory.

~/Workspace/vm/box/[box_name]

So for example My vagrant sync folder mapping is something like this:

local: /home/username/Workspace/vm/box/rusty (box named after dog :slight_smile: )
vm /var/www

Which allows me to just add a new site like below and just manually setup the db and vhost.

vm: /var/www/local.test
local: /home/username/Workspace/vm/box/rusty/local.test

I haven’t been really running into any issues with this setup and it allows me to easily get up and running with a new site if I need to without provisioning boxes if the environment can be the same. It just seems a little unconventional.

Thoughts?

That can work for a team of one but it has holes when you have bigger teams or varied workloads or varied apps. Moreover it really isn’t the way Vagrant wants to work.

Our perversion of Vagrant here is built like this:

  • we have some base projects – eg for static PHP sites or wordpress sites or drupal sites.
  • the base project sets up a template that has enough instructions to build a local dev environment for that platform.
  • concrete examples of the projects have full running info including content – we can get a full running copy of a wordpress site on a designer’s desk in very, very short order.
  • all of this lives under source control
  • same template is checked out on the build servers which deploy to QA or production as needed. We also support multiple QA environments where required.

Provisioning is really just waiting for stuff to download; there really isn’t a whole lot of setup for a new project other than setting a few particulars like site IDs and urls.