Ability to run boot_command a second time

Is it possible to run the boot_commands a second time when building a virtual machine using the vsphere_iso builder?

Reason for this is when building a RHEL virtual machine, I need to add machine operator keys using mokutil which I’m currently doing manually.

Thanks

Did you have any luck?

The tactic that I was taking:

configuration_parameters = {
  “uefi.secureBoot.dbDefault.file0” = "custom-cert.der"
}

But the issue that I have is if Packer runs with a custom certificate referenced in the advanced configuration parameters I can see the parameter tookon the vm, but the vm will not boot. It is stuck on the efi screen, Attempting to start form:
EFI virtual Disk (0.0) … No Media
EFI virtual Disk (1.0) … No Media
EFI virtual SATA CDROM Drive (0.0) … Not Found
EFI virtual SATA CDROM Drive (1.0) … No Media
EFI Network … No Media.

If Packer runs with the debug flag and with the same custom certificate referenced in the advanced configuration parameters I can see the parameter took on the vm. Before the vm boots for the first time if I go in and upload the custom-cert.der to the vm directory then continue with Packer it boots and works as expected.

I think I am looking for a way to upload the certificate after the vm is created but before the vm starts up for the first time. This way the certificate is referenced and available to be added into the vms uefi.

The VMware forums seem to suggest CopyDatastoreFile_Task, but I can’t see how I could trigger that via the configuration_parameters.

I have tried referencing the custom cert from a different file path in the datastore, no success.

I am aware of the vSphere Post-Processor, but this doesn’t really work in this instance.

:upside_down_face: