Search code examples
rubyvagrantchef-infravagrantfileberkshelf

Is Vagrant capable of managing all of a project's servers? (e.g. local, development, staging and production)


A few weeks ago I came across Vagrant and fell in love. I'm currently trying it out on a new project and it's working great locally. I'm using Chef Solo to build all the box's software and Berkshelf to manage the cookbooks.

What I'm wondering is how everyone is managing their development, staging and production severs for each project. While I'm working on this project locally, I would like to have a development server and eventually staging and production servers once the project is complete.

I have successfully setup Vagrant with Amazon's Ec2 using the Vagrant AWS Plugin, but it would appear that Vagrant doesn't let you vagrant up a local box and a development box at the same time, you can only have one.

I wrote a small bash script that basically gives me this capability. I can run

$ vagrant up local
$ vagrant up development
$ vagrant up staging
$ vagrant up production

And it will build each box I specify by looking for a Vagrantfile dedicated to that box's configuration. I have a directory name machines where each vagrant file lives. The directory structure I have looks like this

- app/
- public/
- vagrant/
    - attributes/
    - machines/
      - local.rb
      - development.rb
      - staging.rb
      - production.rb
    - recipes/
    - templates/

Is this a sensible solution?

How are you managing multiple servers for a single project. Can ALL the configuration live in one Vagrantfile, should it?


Solution

  • Please never ever do this. Vagrant is not built for it and it will break. For example, if you ever need to manipulate production instances from a different workstation, good luck :-( If you are looking for tools to manage server provisioning, it is definitely some slim pickings, but there are tools to try:

    • CloudFormation (and Heat for OpenStack)
    • Terraform
    • chef-metal

    The first is a bit ungainly but very powerful if you are all AWS-based (or OpenStack). The latter two are very young but look promising.