Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can single Vagrantfile have both AWS and VirtualBox providers at same time?

I am new to Vagrant and currently trying out provision a VirtualBox and AWS box(using vagrant-aws plugin) from single Vagrantfile.

My Vagrantfile is as shown below:

Vagrant.configure("2") do |config|

    config.vm.define :web do |web_config|
        web_config.vm.box = "dummy"
        web_config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"

        web_config.vm.provider :aws do |aws|
            aws.access_key_id = "ACCESS KEY"
            aws.secret_access_key = "SECRET KEY"
        end
    end

    config.vm.define :db do |db_config|
        db_config.vm.box = "precise32"
        db_config.vm.box_url = "http://files.vagrantup.com/precise32.box"

        db_config.vm.provider :virtualbox  do |vb|

        end     
    end
end

So basically I am trying to have AWS for web and a network box for database. Is it possible to do this from single Vagrantfile? And will the below vagrant up command create and provision both VMs?

vagrant up --provider=aws
like image 814
ganesh Avatar asked Apr 02 '13 15:04

ganesh


1 Answers

By judging from Basic Provider Usage

Limitations

Vagrant currently restricts you to bringing up one provider per machine. If you have a multi-machine environment, you can bring up one machine backed by VirtualBox and another backed by VMware Fusion, for example, but you can't back the same machine with both VirtualBox and VMware Fusion.

This is a limitation that will be removed in a future version of Vagrant.

this is indeed possible! But you have to remember that functions like public and private networks can't be (usually, see Private Networks) used across provider borders.

Regarding the second part of your question I suppose that you need to issue two commands, one for each provider in your multi-vm environment but that's just a guess - there is little official documentation on providers and multi-vm environments.

like image 141
cmur2 Avatar answered Sep 23 '22 17:09

cmur2