All providers run when multiple are included #349
Comments
I removed and it worked for me when I did vagrant up --provider=virtualbox (only vbox provider booted up) |
@smccarthy, I tried that with no avail. |
Happens for me too. Vagrantfile:
Output:
|
According to the documentation:
That's fine as a limitation, but why then, do you have to specify a provider? If the saying is "one provider per box" then it should error when multiple providers are defined for a box or not require you to say Maybe we should summon the almight @mitchellh and see what the correct usage is. ie. "This is what it takes to create a running VM in vbox. In AWS, just point to this base AMI. In Digitalocean, this droplet". I don't want to manage multiple box references in a Vagrantfile when the only difference is that it has metadata for aws, digitalocean, etc. |
@myoung34 I interpreted the limitation you mention differently: a single Vagrantfile can support multiple providers but you can have only a single running machine--using a single provider--from each Vagrantfile instance. So for a Vagrantfile that supports openstack and virtualbox, I observe
As a Vagrantfile novice, I find the behaviour noted by you and @blaw2422 (and now me, that's how I got here) mysterious: Vagrant doesn't run all of the code for the unspecified providers--i.e. running |
@chris-redekop, that's the same question I asked. That's why we used code determine what was called in order to ensure when code is called |
I don't think it is a vagrant-aws only issue, the same happens to me with a Vagrantfile that includes config.vm.provider sections for virtualbox and vmware_fusion. |
Yes, you should be able to supply multiple configurations in your Vagrantfile to allow users to use their favorite provider, however, code that you place in a provider-specific blocks should not run unless you are provisioning using that provider. Instead of that behavior, you're allowed to specify multiple providers, but they all run no matter what! I am also having this problem; it's very counterintuitive, and ugly to hack around. |
There ought to be a way to make this less ugly, that avoids processing command line arguments! Isn't there a variable indicating which provider was selected? |
I can get multiple providers to work together (virtualbox, aws, and digital_ocean) if I run So maybe one solution is to name all the guests of a provider when using |
Example Vagrantfile please? |
Thanks. So you're suggesting that you can vagrant up the virtualbox provider without the environment variables set? |
Just unset my aws credential variables, and See my I bring the guests up with:
Notice no |
Thanks! I will definitely try that. Now, does it also ignore provisioners defined in those other providers? Hmm. On Fri, Nov 13, 2015 at 10:48 PM, DEFN notifications@github.com wrote:
|
Problem
Including 2 providers in 1 Vagrant file causes both to run no matter which command I use, or how I call it.
Usage
vagrant up --provider=virtualbox
will cause code in both providers to execute.When the AWS provider runs, it will make sure all values are provided, or will raise exception. The values are not required for virtualbox, but still fail when I try to use virtualbox.
Solution
Use conditional statements in the providers to determine if the block should execute based on the provider specified in the
vagrant
command.Example Vagranttfile
The text was updated successfully, but these errors were encountered: