hashicorp / packer-plugin-virtualbox

Packer plugin for VritualBox Builder
https://www.packer.io/docs/builders/virtualbox
Mozilla Public License 2.0
22 stars 36 forks source link

Exported EFI VM's do not include relevant NVRAM files #54

Open shoddyguard opened 2 years ago

shoddyguard commented 2 years ago

Overview of the Issue

Sometimes when running EFI VM's NVRAM files can be created, at the moment these get cleaned up when the VM is deleted after Packer has exported it, however these may be necessary for the VM to boot as the resulting OVF file will reference them:

<BIOS>
        <IOAPIC enabled="true"/>
        <NVRAM path="/Users/steve.brown/Documents/Repos/Personal/os-provisioning/.build/output/macOS_11/vbox/macOS11-base/macOS11-base.nvram"/>
        <SmbiosUuidLittleEndian enabled="true"/>
 </BIOS>

Unfortunately Virtualbox doesn't offer a way to change the NVRAM location at export time natively, perhaps it could be achieved with an API call?

In my production environment I am using CI/CD to copy the NVRAM file to the Packer output directory and then edit the XML of the resulting OVF file to change the location of the NVRAM file, though it's my belief Packer should handle this natively.

At the moment this only seems to affect macOS, but I should imagine as more things make use of NVRAM files this will be more of an issue.

Reproduction Steps

Build an image that uses EFI firmware and stores NVRAM output (at the moment this appears to be just macOS) Import the OVF file It will be un-bootable until you update the location of the NVRAM file

Plugin and Packer version

❯ packer version
Packer v1.7.8

Simplified Packer Buildfile

https://gist.github.com/shoddyguard/01f726a357d87fa873eb0f92d7b6ee47

Operating system and Environment details

macOS 12.1 host OS and macOS 11/12 VM

Log Fragments and crash.log files

N/A