Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable virtualbox-* builders to preserve .vdi format when chaining templates so disks can be resized in later stages #25

Open
ghost opened this issue May 19, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented May 19, 2021

This issue was originally opened by @timblaktu as hashicorp/packer#10982. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


On our CI system, we've used a layered, template-chaining approach to building VMs, wherein we:

  • build base_images from iso with virtualbox-iso
    • currently these are being exported as ovf
  • build more "layers" of base images from the above .ovf using virtualbox-ovf
  • build final customized user images from any of the above .ovf using virtualbox-ovf
    • customization includes expanding the virtual disk included in the .ovf

Following this approach it does not initially appear possible to resize the virtual disk in the final virtualbox-ovf build stage because:

I see that the virtualbox-iso stepCreateDisk function hard-codes the virtual disk format to VDI. This is good because I think I can now assume that the only reason I'm getting a .vmdk is that I'm exporting to .ovf.

Without exporting from virtualbox-iso/importing into virtualbox-ovf, how can I "chain" packer virtualbox builds, while preserving the vdi file format?

I have gathered minor pieces of this puzzle, such as:

  1. I know I can skip_export but I don't see how I can import the machine with converting to ovf.
  2. I know I can vboxmanage and vboxmanage-post any commands I want, but finding the right sequence eludes me. I could clone the .vmdk as a .vdi in any build stage, but I don't understand what builder can accept a .vdi as input.

This just feels like a lot of work to figure out how to do something quite simple. FWIW I implemented this same idea effortlessly using vsphere-iso/vsphere-clone builders - all I had to do was specify the disk size in the downstream vsphere-clone builder.

Anyone have any ideas or suggestions?

@horihel
Copy link

horihel commented May 20, 2021

you could go with specifying import_opts = "importtovdi" in your source, but that still leaves you with the problem that vboxmanage modifymedium expects you to know either the full path or the UUID of the created disk.
You might be able to guess/hardcode the full path though

@ardrigh
Copy link

ardrigh commented May 10, 2023

Did the suggestion from the forum work?

https://discuss.hashicorp.com/t/enable-virtualbox-builders-to-preserve-vdi-format-when-chaining-templates-so-disks-can-be-resized-in-later-stages/23815/2

Off the top of my head I think you want to use the keep_registered flag in the virtualbox-iso build and then use the virtualbox-vm builder rather than the virtualbox-ovf builder. You don’t even need to pass in the .vdi file, just reference the name given to the vm in the prior build by setting vm_name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants