Vagrantfile: Switch config vars based on provider (virtualbox, digital_ocean)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Vagrantfile: Switch config vars based on provider (virtualbox, digital_ocean)?

Robert Dickert
Hi, first time poster here. I've been using Vagrant with Virtualbox and the newly enabled Ansible provisioning with joy :-)

Now I'd like to try my Ansible code on a vps with the Digital Ocean plugin. My thought is it would be nice to be able to go to my project directory and either call `vagrant up --provider=virtualbox` or `vagrant up --provider=digital_ocean` and get what I want. However, a couple of variables are incompatible between the two if I want them in the same Vagrantfile. `config.ssh.private_key_path` is required to be set for Digital Ocean but breaks my virtualbox provisioning, which needs the insecure key, and I need port-forwarding on Virtualbox but not DO. Also, the `config.vm.box` itself seems to not be configurable per-provider.

Is there a way I can set these variables conditionally based on the --provider passed to Vagrant? Or is there a different intended way to accomplish what I want to do? I know I could just have two different Vagrantfiles in different directories, but that seems a little odd in my situation. I take it from the documentation that even if I succeed at this, I won't be able to provision both VB and DO from the same project folder (correct?), so maybe I should be looking at a different workflow for this use case under Vagrant 1.2. I'm not a Rubyist and am pretty new to this, so I may also just be missing something. Thanks for your thoughts on this.

Robert

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Vagrantfile: Switch config vars based on provider (virtualbox, digital_ocean)?

Alfredo Aguirre
Hi Robert,

I haven't used the Digital Ocean provider, but I have provider specific options:


Hope this helps.

Cheers,

A

On 26 Apr 2013, at 01:59, Robert Dickert <[hidden email]> wrote:

Hi, first time poster here. I've been using Vagrant with Virtualbox and the newly enabled Ansible provisioning with joy :-)

Now I'd like to try my Ansible code on a vps with the Digital Ocean plugin. My thought is it would be nice to be able to go to my project directory and either call `vagrant up --provider=virtualbox` or `vagrant up --provider=digital_ocean` and get what I want. However, a couple of variables are incompatible between the two if I want them in the same Vagrantfile. `config.ssh.private_key_path` is required to be set for Digital Ocean but breaks my virtualbox provisioning, which needs the insecure key, and I need port-forwarding on Virtualbox but not DO. Also, the `config.vm.box` itself seems to not be configurable per-provider.

Is there a way I can set these variables conditionally based on the --provider passed to Vagrant? Or is there a different intended way to accomplish what I want to do? I know I could just have two different Vagrantfiles in different directories, but that seems a little odd in my situation. I take it from the documentation that even if I succeed at this, I won't be able to provision both VB and DO from the same project folder (correct?), so maybe I should be looking at a different workflow for this use case under Vagrant 1.2. I'm not a Rubyist and am pretty new to this, so I may also just be missing something. Thanks for your thoughts on this.

Robert

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Vagrantfile: Switch config vars based on provider (virtualbox, digital_ocean)?

Mitchell Hashimoto
Robert, Alfredo,

No! Don't do this the way you're doing it! That actually doesn't work.

What you want is here: http://docs.vagrantup.com/v2/providers/configuration.html (search for "override")

Best,
Mitchell


On Fri, Apr 26, 2013 at 4:46 AM, Alfredo Aguirre <[hidden email]> wrote:
Hi Robert,

I haven't used the Digital Ocean provider, but I have provider specific options:


Hope this helps.

Cheers,

A

On 26 Apr 2013, at 01:59, Robert Dickert <[hidden email]> wrote:

Hi, first time poster here. I've been using Vagrant with Virtualbox and the newly enabled Ansible provisioning with joy :-)

Now I'd like to try my Ansible code on a vps with the Digital Ocean plugin. My thought is it would be nice to be able to go to my project directory and either call `vagrant up --provider=virtualbox` or `vagrant up --provider=digital_ocean` and get what I want. However, a couple of variables are incompatible between the two if I want them in the same Vagrantfile. `config.ssh.private_key_path` is required to be set for Digital Ocean but breaks my virtualbox provisioning, which needs the insecure key, and I need port-forwarding on Virtualbox but not DO. Also, the `config.vm.box` itself seems to not be configurable per-provider.

Is there a way I can set these variables conditionally based on the --provider passed to Vagrant? Or is there a different intended way to accomplish what I want to do? I know I could just have two different Vagrantfiles in different directories, but that seems a little odd in my situation. I take it from the documentation that even if I succeed at this, I won't be able to provision both VB and DO from the same project folder (correct?), so maybe I should be looking at a different workflow for this use case under Vagrant 1.2. I'm not a Rubyist and am pretty new to this, so I may also just be missing something. Thanks for your thoughts on this.

Robert

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Vagrantfile: Switch config vars based on provider (virtualbox, digital_ocean)?

Alfredo Aguirre
I didn't know about override. Thanks for the tip!

A

On 26 Apr 2013, at 16:46, Mitchell Hashimoto <[hidden email]> wrote:

Robert, Alfredo,

No! Don't do this the way you're doing it! That actually doesn't work.

What you want is here: http://docs.vagrantup.com/v2/providers/configuration.html (search for "override")

Best,
Mitchell


On Fri, Apr 26, 2013 at 4:46 AM, Alfredo Aguirre <[hidden email]> wrote:
Hi Robert,

I haven't used the Digital Ocean provider, but I have provider specific options:


Hope this helps.

Cheers,

A

On 26 Apr 2013, at 01:59, Robert Dickert <[hidden email]> wrote:

Hi, first time poster here. I've been using Vagrant with Virtualbox and the newly enabled Ansible provisioning with joy :-)

Now I'd like to try my Ansible code on a vps with the Digital Ocean plugin. My thought is it would be nice to be able to go to my project directory and either call `vagrant up --provider=virtualbox` or `vagrant up --provider=digital_ocean` and get what I want. However, a couple of variables are incompatible between the two if I want them in the same Vagrantfile. `config.ssh.private_key_path` is required to be set for Digital Ocean but breaks my virtualbox provisioning, which needs the insecure key, and I need port-forwarding on Virtualbox but not DO. Also, the `config.vm.box` itself seems to not be configurable per-provider.

Is there a way I can set these variables conditionally based on the --provider passed to Vagrant? Or is there a different intended way to accomplish what I want to do? I know I could just have two different Vagrantfiles in different directories, but that seems a little odd in my situation. I take it from the documentation that even if I succeed at this, I won't be able to provision both VB and DO from the same project folder (correct?), so maybe I should be looking at a different workflow for this use case under Vagrant 1.2. I'm not a Rubyist and am pretty new to this, so I may also just be missing something. Thanks for your thoughts on this.

Robert

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.