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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to