hashicorp / hashicorp/packer-plugin-virtualbox

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

Open
#25 2 comments 0 reactions 0 assignees View on GitHub
enhancement track-internal
Dominant language
Go
Stars
29
Forks
45
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @timblaktu as hashicorp/packer#10982. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). 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:
* `virtualbox-iso` exports as .ovf/.ova, which more or less requires VMware's .vdmk format
* `vboxmanage modifymedium --resize` [only supports .vdi/.vhd formats](https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifymedium)

I see that the `virtualbox-iso` [stepCreateDisk function](https://github.com/hashicorp/packer/blob/v1.7.2/builder/virtualbox/iso/step_create_disk.go#L25) 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](https://www.packer.io/docs/builders/virtualbox/iso#skip_export) but I don't see how I can import the machine with converting to ovf.
2. I know I can [vboxmanage](https://www.packer.io/docs/builders/virtualbox/iso#vboxmanage) and [vboxmanage-post](https://www.packer.io/docs/builders/virtualbox/iso#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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.