Vmware-iso fully-headless export without SSH / shutdown command

I have a Fedora Anaconda kickstart and installer that is fully headless and includes packages in the ISO itself at build-time (eg, not an actual network install) - it shuts down immediately after completion via kickstart command.

My current process for producing an OVA from these installers is to install the ISO into a new VM manually with the ISO attached, let the installer complete naturally, and then export the resulting VM to an OVA after.

vmware-iso seems like a good way to automate this process and save some time.

{
"builders": [{
    "type": "vmware-iso",
    "iso_url": "https://git.company.com/production-images/raw/tagged-installer-2020-02-04.iso",
    "iso_checksum": "8812f6758aae125346a0ee8b9f42829c4299e869c61d710442a4ca97074e1b3c",
    "ssh_username": "root"
}]
}

Is there any way to skip the SSH commands here and just export the VM as-is after we detect that it is shut down?

Warnings for build 'vmware-iso':

* A shutdown_command was not specified. Without a shutdown command, Packer
will forcibly halt the virtual machine, which may result in data loss.

==> vmware-iso: Retrieving ISO
==> vmware-iso: Trying https://git.company.com/production-images/raw/tagged-installer-2020-02-04.iso
==> vmware-iso: Trying https://git.company.com/production-images/raw/tagged-installer-2020-02-04.iso?checksum=8812f6758aae4945f6a0ee8b9f42829c4299e869c61d710442a4ca97074e1b3c
==> vmware-iso: https://git.company.com/production-images/raw/tagged-installer-2020-02-04.iso?checksum=8812f6758aae4945f6a0ee8b9f42829c4299e869c61d710442a4ca97074e1b3c => /Users/myuser/Development/packer/packer_cache/f1c0a03
0d1009448f114328ec7418173f8121141.iso
==> vmware-iso: Creating required virtual machine disks
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 10s for boot...
==> vmware-iso: Connecting to VM via VNC (127.0.0.1:5914)
==> vmware-iso: Typing the boot command over VNC...
==> vmware-iso: Waiting for SSH to become available...
==> vmware-iso: Timeout waiting for SSH.
==> vmware-iso: Stopping virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Timeout waiting for SSH.

This workaround should help you: https://github.com/hashicorp/packer/issues/1591#issuecomment-225784414

Hmm, I see that the correct boot option is chosen now, but the device is immediately forcibly halted after the “boot_command” is executed:

...
==> vmware-iso: Creating required virtual machine disks
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 10s for boot...
==> vmware-iso: Connecting to VM via VNC (127.0.0.1:5927)
==> vmware-iso: Typing the boot command over VNC...
==> vmware-iso: Forcibly halting virtual machine...
    vmware-iso: Waiting for VMware to clean up after itself...
==> vmware-iso: Deleting unnecessary VMware files...
    vmware-iso: Deleting: output-vmware-iso/TW-Connect-2.0-packer-test.plist
    vmware-iso: Deleting: output-vmware-iso/startMenu.plist
    vmware-iso: Deleting: output-vmware-iso/vmware.log
==> vmware-iso: Compacting all attached virtual disks...
    vmware-iso: Compacting virtual disk 1
==> vmware-iso: Cleaning VMX prior to finishing up...
    vmware-iso: Detaching ISO from CD-ROM device ide0:0...
    vmware-iso: Disabling VNC server...
==> vmware-iso: Skipping export of virtual machine (export is allowed only for ESXi)...
Build 'vmware-iso' finished.

Shouldn’t the “pause_before_connecting” command handle that?

"shutdown_command": "",
"pause_before_connecting": "5m",
"boot_command": [
    "<down>",
    "<down>",
    "<down>",
    "<enter>"
]
}]
}

Is your boot_command correct? Here (https://github.com/kaorimatz/packer-templates/blob/master/fedora-28-x86_64.json) is one for Fedora 28. I’m using Ubuntu, so i don’t know what should be the right one. :slight_smile:

Here is another example: https://github.com/mrlesmithjr/packer-templates/blob/master/Fedora/fedora-server.json

It is correct ; we have a custom ISO builder that embeds the kickstarts and scripts onto the actual boot media. The proper option here happens to be the third one down.

The use case we have is a single, completely standalone ISO installer that we can checksum and send to a hardware manufacturer AND produce VMWare images from.

Incidentally, if I add a wait10m to the boot command things work like I would expect (though the OVA is not exported automatically since Fusion won’t export to an OVA.

1 Like