Hey Torben,
That is a good suggestion, but we are trying to avoid asking anyone to
change Vagrantfiles in the default load path.
We got to a working solution - call the following, where env is @env from
your Command.
config_proc = proc do |config|
config.vm.box = 'precise64'
end
loader = env.config_loader
loader.set(:my_base, [['2', config_proc]])
env.instance_variable_set(
:@vagrantfile,
Vagrant::Vagrantfile.new(loader, [:my_base, :home, :root])
)
On Friday, October 10, 2014 1:49:33 AM UTC-6, Torben Knerr wrote:
>
> Hi,
>
> A more lightweight approach would be to distribute a default Vagrantfile
> and ask users to put it in their ~/.vagrant.d/ directory
>
> You could enable / disable your company specific defaults with an env var
> for example
>
> Cheers,
> Torben
> Am 10.10.2014 01:57 schrieb "Chris Chalstrom" <[email protected]
> <javascript:>>:
>
>> I'm working on a plugin to be used for simplifying the process of
>> deploying to my org's environment. As part of this, I'd like to package
>> some default configuration that would typically go into the Vagrantfile
>> into my plugin.
>>
>> My goals are to allow anyone to use my plugin OR standard vagrant
>> commands without having to put anything referencing my plugin into their
>> Vagrantfiles. But my plugin would allow them to choose some default
>> machine configuration options, e.g. config.vm.box = 'precise64'.
>>
>> I'd like them to be able to run `vagrant my_plugin up` and get a machine
>> running even when they have an empty Vagrantfile.
>>
>> Right now I'm making my own version of the Up command, which will
>> ultimately call the native Up. I've tried lots of different ways of doing
>> this, and I can't quite figure out how to make it work.
>>
>> The latest thing I've tried is as follows (please forgive the pseudocode,
>> but I don't have access to my actual code at the moment):
>>
>> class MyUp < Vagrant.plugin(2, :command)
>> def initialize(argv, env)
>> super
>>
>> loader = @env.config_loader
>> p = proc do
>> Vagrant.configure(2) do |config|
>> config.vm.box = 'precise64'
>> end
>> end
>>
>> loader.set(:my_base, [[2, p]])
>> loader.load [:my_base, :root, :home]
>> end
>>
>> def execute
>> Vagrant.UpCommand.new(@argv, @env).execute
>> end
>> end
>>
>> This, along with many other things including loading Vagrantfiles with
>> the Vagrant::Vagrantfile, and Vagrant::Config::Loader do not work. No
>> matter what I try, I will get an error because vm.box has not been
>> specified.
>>
>> What is the best way for me to supply some default vm config with my
>> vagrant plugin?
>>
>> Thanks
>>
>> --
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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.