Building a Ubuntu 22.04 server image with the Hyper-V builder for Packer. Packer however never seems to find the IP address of the machine.
==> hyperv-iso: Starting HTTP server on port 8882
==> hyperv-iso: Creating switch 'public' if required...
==> hyperv-iso: switch 'public' already exists. Will not delete on cleanup...
==> hyperv-iso: Creating virtual machine...
2022/12/12 20:01:40 packer.exe plugin: No existing virtual harddrive, not attaching.
==> hyperv-iso: Enabling Integration Service...
==> hyperv-iso: Mounting os dvd drive C:/Tools/ubuntu_server.iso ...
2022/12/12 20:01:50 packer.exe plugin: No floppy disk, not attaching.
==> hyperv-iso: Skipping mounting Integration Services Setup Disk...
2022/12/12 20:01:50 packer.exe plugin: No CD files specified. CD disk will not be made.
==> hyperv-iso: Mounting secondary DVD images...
==> hyperv-iso: Configuring vlan...
==> hyperv-iso: Determine Host IP for HyperV machine...
==> hyperv-iso: Host IP for the HyperV machine: 192.168.1.111
==> hyperv-iso: Attempting to connect with vmconnect...
==> hyperv-iso: Starting the virtual machine...
==> hyperv-iso: Waiting 10s for boot...
==> hyperv-iso: Typing the boot command...
............................. (removed the boot command).........................
2022/12/12 20:02:17 packer.exe plugin: [DEBUG] Unable to get address during connection step: No ip address.
==> hyperv-iso: Waiting for SSH to become available...
2022/12/12 20:02:17 packer.exe plugin: [INFO] Waiting for SSH, up to timeout: 20m0s
2022/12/12 20:02:22 packer.exe plugin: [DEBUG] Error getting SSH address: No ip address.
The installation completes but an address for Packer to SSH against is never discovered. The machine does get an IP address however and I can manually SSH to it.
According to the documentation Packer should automatically attach the 'Integration Services Setup Disk' but the log says that it is skipping it, guessing this is the issue? But I cannot find a way to fix it.
Hyper-V integration services need to be installed in order for Packer to be able to retrieve the IP address of the guest VM from Hyper-V.
I resolved this by adding the following packages to my cloud-init user-data file: