Yes, that is eventually how I solved this issue. I actually tried using ARGV, which would have been preferred, but discovered that vagrant’s processing of arguments doesn’t appear to be extensible and barfs at any arguments it does’t know about. It would be nice if vagrant just ignored anything it didn’t understand, however I can see how that could cause issues downstream, but I can’t imagine ENV vars are much better. Maybe if there was a similar syntax as vagrant ssh where anything after the lone ‘--‘ was passed onto the Vagrantfile. Hint - this would be a nice orthogonal design pattern to have for all commands that interact with the Vagrantfile or another application.
Thanks everyone, - Jim > On Apr 9, 2015, at 9:10 AM, dragon788 <[email protected]> wrote: > > As Alvaro said, the easiest way is through ENV variable magic. You can prefix > your vagrant up with some instance ENV vars and then access those via the ENV > call he outlined. > > ENV1=prod ENV2=official vagrant up > > If you are more comfortable with ruby you could also do some rudimentary > argument parsing, but that could easily bump into vagrant's arg parsing, so > the other option if ENV isn't your bag, would be having a file with the > options you want to use, and then use Ruby to read in the options from the > file, this file could be something like dev-env / prod-env and you have a > copy with different variables depending on your branch (if you are using the > Vagrantfile from a code repo). > > On Thursday, April 9, 2015 at 2:30:23 AM UTC-5, Jim Klo wrote: > Relatively new to Vagrant as well as Ruby. > > I've got a multi-box Vagrantfile and wondering if there's a way for me to > pass additional command-line arguments to vagrant-up that I can process > within the Vagrantfile. > > For example, I've got a VM that provisions a server by default against a > specific official release of a source repo, however I'd like to have the > ability to just pass an argument or flag that can be processed to do some > additional provisioning by changing the source repo to different branch. I > suppose I could do this using subsequent calls after the vagrant-up with > vagrant-ssh, but was hoping to have a handy one-liner. > > Thanks, > > - Jim -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
