hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
94 stars 91 forks source link

Option to include .nvram file when exporting VM to OVF #95

Closed jaymzmac closed 2 years ago

jaymzmac commented 3 years ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

The export function in the vsphere-iso builder has no option to include the VM's .nvram file in the OVF export.

Here is my export config:

"export": {
        "force": true,
        "images": false,
        "output_directory": "./output_vsphere"
      },

And here is the resulting list of files for a VM build with Packer 1.6.4:

ls -l /builds/ops/vmware/packer/debian11/output_vsphere/
packer-debian-11-20210802-175037-disk-0.vmdk
packer-debian-11-20210802-175037.mf
packer-debian-11-20210802-175037.ovf

This is a problem with EFI based VMs because the nvram file includes boot variables that are used to locate the bootloader.

If a VM is deployed from this OVF where the nvram file is missing, then the resulting VM will fail to boot into the OS.

However, I have verified that when the OVF includes the nvram file (for example, when using export OVF through vCenter), then the resulting VMs are successfully able to boot into the OS.

EFI VMs are becoming more mainstream, so I think it's important to include this option in the packer vsphere-iso builder.

Potential References

https://flings.vmware.com/esxi-arm-edition/comments/19176#comment_19184 https://blog.amanshortly.com/importing-ovf-templates-of-vms-that-use-uefi-boot-mode/ https://github.com/ansible-collections/community.vmware/blob/main/plugins/modules/vmware_export_ovf.py#L245

nywilken commented 2 years ago

Hi there @jaymzmac we had sometime to look into this request and it turns out that support for the exporting of .nvram files is supported when setting images = true in the export configuration. I opened a PR https://github.com/hashicorp/packer-plugin-vsphere/pull/132 to update the documentation for the images argument, and also added a new argument called images_files which should help you and other in the future.

The documentation change, along with the new image_files argument will be available in the next release.