Packer connecting to Ubuntu "too early", how to enforce a delay?

Making an Ubuntu 20.04 template using the vsphere-iso builder, and Packer v1.7.7, I’m seeing a problem where the provisioner starts attempting to connect to the VM way too early, basically as soon as the VM starts reporting the ip address obtained via DHCP to VSphere, this happens roughly 3min into the process. This results in repeatedly failing ssh login attempts:

2021/10/24 20:50:31 packer-builder-vsphere-iso plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2021/10/24 20:50:38 packer-builder-vsphere-iso plugin: [INFO] Attempting SSH connection to my.ip.address.here:22…
2021/10/24 20:50:38 packer-builder-vsphere-iso plugin: [DEBUG] reconnecting to TCP connection for SSH
2021/10/24 20:50:38 packer-builder-vsphere-iso plugin: [DEBUG] handshaking with SSH
2021/10/24 20:50:41 packer-builder-vsphere-iso plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

And Packer gives up on the entire thing way before the installation process is finished and the machine is rebooted with the install finished, SSH enabled and packer user present. It looks as if “pause_before_connecting” is not a solution, as according to documentation and various dev comments, it only pauses provisioners, not actual connection attempts, which would still continue and eventually cause failure.

I haven’t had this issue with Redhat-family of distributions as seemingly they don’t immideately start reporting their ip to vsphere, but only after I separately install and start the vmtoolsd service. But Ubuntu behaves differently here, reporting the obtained up upwards very quickly, resulting in a build failure. How can I force Packer to not attempt any SSH connections during the first boot of the build or force in a delay?

Worked around this issue using:

early-commands:

  • systemctl stop ssh

In my user-data for subiquity installer. Now I need to figure out how to make Packer pick up the new dhcp-obtained ip address, which changed happened after the first reboot. And also how to have subiquity not throw a total fit if the installation attempts installing multiple services with some of them failing to immideately launch (the idea is to clean-up irrelevant hypervisor services via ansible post-install).