Customize Vagrant before importing the image disk #1247

Closed
willdurand opened this Issue Dec 6, 2012 · 6 comments

Projects

None yet

2 participants

@willdurand
Contributor

Heya,

Vagrant allows to customize the VirtualBox VM by using the config.vm.customize key in the Vagrantfile. Under the hood, this uses vboxmanage and you can find more information here: config.vm.customize.

Thing is, vboxmanage can also manage "global" properties, like the defaultMachineFolder:

vboxmanage setproperty machinefolder "/path/to/your/VirtualBox VMs/"

It's not possible to use Vagrant to run this command as customizations are executed after the image disk importation.

So my question is, could it be possible to run customizations before everything else? I guess it's not supported yet (or I missed something), so could it be an improvement?

Thanks,
William

@mitchellh
Owner

William,

This sounds fine to me. This isn't something I'd put back in 1.0.x but moving forward could be an option. My question: Are there any customizations that need to be run AFTER importing the disk? I'm afraid moving this would break some things.

Mitchell

@willdurand
Contributor

Are there any customizations that need to be run AFTER importing the disk?

According to the VBoxManage documentation, "most of [the VBoxManage] subcommands require that you specify a particular virtual machine after the subcommand.". IMO we should not change the existing process. Tweaking the VM should be done once the disk is imported.

VBoxManage subcommands that don't need a UUID:

  • list
  • registervm
  • createvm
  • import
  • export
  • createhd
  • setproperty
  • metrics
  • dhcpserver
  • extpack

To be more generic (as VirtualBox isn't the only thing we should consider now), I think we should find a name for these tasks that need to be performed before importing the disk, maybe like a hook: config.vm.pre_import.

What do you think?

@mitchellh
Owner

I like this idea. I'm just trying to think of terminology to use but I think I can get this in before 1.1.

@willdurand
Contributor

Would it be possible to have config.vm.customize.pre_import? That would
leave the door open to further hooks, without breaking BC (hopefully).

William Durand | http://www.williamdurand.fr

On Thu, Jan 31, 2013 at 7:05 AM, Mitchell Hashimoto <
notifications@github.com> wrote:

I like this idea. I'm just trying to think of terminology to use but I
think I can get this in before 1.1.


Reply to this email directly or view it on GitHubhttps://github.com/mitchellh/vagrant/issues/1247#issuecomment-12929128.

@mitchellh
Owner

Finally this feature is done. The old syntax doesn't change. But you can now do this:

v.customize "pre-boot", ["command", "to", "run"]
@mitchellh mitchellh closed this Jul 23, 2013
@willdurand
Contributor

\o/ thanks! 🎆 🌟

@dldinternet dldinternet pushed a commit to dldinternet/vagrant that referenced this issue Aug 26, 2013
@mitchellh + Christo DeLange VBoxManage customizations can run at different events [GH-1247] e5b4bec
@dldinternet dldinternet pushed a commit to dldinternet/vagrant that referenced this issue Sep 1, 2013
@mitchellh + Christo DeLange VBoxManage customizations can run at different events [GH-1247] f7d2259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment