Stalled install with Packer + Proxmox + Ubuntu 22.04.2

I’m trying to use Packer to create an Ubuntu 22.04 template on Proxmox.
I was following Christian Lempa’s Youtube Video: Create VMs on Proxmox in Seconds! - YouTube

My config:

It gets stuck.

Meanwhile packer is waiting for ssh and eventually times out.

$ packer build -var-file="../credentials.pkr.hcl" ./ubuntu-server-jammy.pkr.hcl
ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: output will be in this color.

==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Creating VM
==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Starting VM
==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Starting HTTP server on port 8567
==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Waiting 5s for boot
==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Typing the boot command
==> ubuntu-server-jammy.proxmox-iso.ubuntu-server-jammy: Waiting for SSH to become available...

I managed to find someone with the same issue on Christian’s Github.

It looks like they solved it by running from a different vm already in Proxmox instead of locally.
I’m trying to run this from WSL on Windows.
Is there a way to make it work from local or should I abandon that idea and just run it from a vm like the other guy did?

I also went through many weeks of pain with this. I needed

  1. WSL2 to respond with the user-data file
  2. VM to be able to access the network

To solve the user-data serving issue I needed the correct boot_command which VMWare provide and to set a single port for Packer to listen on with

    http_port_max = 8336  # hardcoded as it's port-forwarded on Windows PC to WSL2
    http_port_min = 8336  # using netsh in admin cmd window below

and you have to port forward 8336 to your WSL2 machine on its ip address using Windows administrator console

netsh interface portproxy add v4tov4 listenport=8336 listenaddress= connectport=8336

Proxmox will request http://<windows-pc-ip>:8336/user-data and the port forwarding will serve that from http://<WSL2-ip>:8336/user-data

In addition <windows-pc-ip>:8336 needs to be open in the Windows firewall

You can curl http://<windows-pc-ip>:8336/user-data the same URL from Proxmox host whilst Packer is waiting to check that Packer is correctly serving the file. If the build still is not obtaining the file, then you may have to solve step 2. I introduced this before autoinstall part of the boot_command

        "ip=::::::dhcp::: ",    # autoconf=dhcp

and with that, the Packer built VM was able to access other devices on the network, obtain the user-data file and finally after weeks of soul destroying frustration, it was possible to see things take shape. It was then only a short amount of time to get Mantic building as well.

I’m not entirely sure why, but the following also helped get better consistency in builds working

boot_key_interval = "150ms"