[Vagrantfile] - Possible to use multi-provider to create a hybrid (local/cloud) dev environment?

53 views
Skip to first unread message

Joe Reid

unread,
Oct 26, 2015, 3:37:24 PM10/26/15
to Vagrant
Hey guys,

I want to create a hybrid development environment using local VMs and one node on EC2.

We have hit the memory limit of what we can run locally in Vagrant with our workstations.  I am looking to break off a subset of the code (a service) and provision it to EC2.   

Ideally, I would like to build a hybrid set up with the three VMs we have now running locally (on VirtualBox) and a fourth node, configured in the same Vagrantfile, running on AWS.  For extra credit, I would like to use Consul to abstract away the EC2 IP for the three local nodes when they make RESTful API requests to the fourth box (service).

Essentially I want to build a box with one service on it, throw it on the cloud, and let the three VMs access it via the service's API.

Can I do this?  I have spent some time with the vagrant-aws plugin and looking over the official docs.  I see how to build a Vagrantfile that can deploy all nodes to AWS (using vagrant up --provider=aws) or all nodes to Virtualbox.  But no examples of how to run a hybrid setup.  I can't find anything on StackOverflow or in the official Vagrant docs.

Is this a supported use case?  If so, what does the Vagrantfile need to look like?  

For example, I build and deployed the following using the vagrant-aws docs:

  config.vm.box = "dummy"
  config.vm.provider :aws do |aws, override|
    aws.access_key_id = ENV['AWS_ACCESS_KEY']
    aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
    aws.keypair_name = "korrelate2012"
    aws.ami = "ami-7747d01e"
    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "~/.ssh/test.pem"
  end

How could I integrate that into a Vagrantfile defining three local VMs?   

Alvaro Miranda Aguilera

unread,
Oct 27, 2015, 2:52:23 AM10/27/15
to vagra...@googlegroups.com
Hello,

I am not sure if will be possible, but won't be easy.

You can create 2 folders and have separate Vagrantfiles.

The reason behind that, is Vagrant will load the Vagrantfile and
create a secuence to run, and then will execute it.

So if you define one VM to use one provider, I am not sure your will
be able to cut that into 2 separate runs.

What you can try is.

Create a Vagranfile as in multi-machine

and then start the VMs separately

ie:

vagrant up myawsbox --provider=aws
vagrant up myvirtualbox --provder=virtualbox

Once the VMs are created, vagrant halt/vagrant stop/vagrant up *should* work

Alvaro
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/a269348e-4404-4f5a-a683-b636efcaec01%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Torben Knerr

unread,
Oct 28, 2015, 7:43:56 AM10/28/15
to vagra...@googlegroups.com
Afaik you can use multiple providers in a single Vagrantfile. That was added in vagrant 1.7:

HTH, Torben

Reply all
Reply to author
Forward
0 new messages