2

I want to use Vagrant and Ansible to mirror the production environment and infrastructure locally. I have setup a Vagrant file along with each Project/Website (App1, App2, ...) I'm working on. For easier maintenance and clarity, I want to use one server gathering statsd, logs and other metrics + pulling backups.

+-----------+    +-----------+
|    App1   |    |  Metrics  |
|           +-+--+  Backups  |
+-----------+ |  +-----------+
              |               
+-----------+ |               
|    App2   | |               
|           +-+               
+-----------+   

Since the Metrics/Backup server is not really part of the website projects, I think the best way is to introduce a dedicated "backup project" with its own Vagrant file. Now some questions/concerns regarding this setup.

  1. Lets say I'm working on App1. To start testing, I have Vagrant up on both App1 and the Metric server. Is there a better way to start them at once?
  2. In general, is it a good idea to use vagrant for infrastructure related servers like backup, which are not essential for the website to function?
  3. Can I link multiple "instances" of Vagrant via private networking?
Akkumulator
  • 995
  • 1
  • 9
  • 26

1 Answers1

1

I take the assumption you will have a single Vagrantfile to manage all 3 environments (you can read more http://docs.vagrantup.com/v2/multi-machine/)

  1. if you manage all 3 environments in a single Vagrantfile vagrant up will start all 3 by default. you can define an autostart property to define which one should be up by default so you can only start 2 by default:

    config.vm.define "App1"
    config.vm.define "Backup"
    config.vm.define "App2", autostart: false
    

If you manage different project, you will need to run vagrant up on each of the project to start the corresponding vm.

  1. it will depend on your requirement. If you want to replicate as close as possible your prod, you should manage this environment

  2. yes you can either communicate by IP or hostname (see Can Multiple Vagrant VMs communicate by VM hostname?)

Community
  • 1
  • 1
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139