Trouble creating Ubuntu 22.10 template in vSphere Stuck on "Waiting for SSH to become available:

Hi folks, trying to figure out packer to build ubuntu server templates using packer in vSphere and can’t get one done.

I’m following closely the guide by Sam Gabrail: https://gitlab.com/public-projects3/infrastructure-vmware-public/vmware-packer-ubuntu22.04-public and with the only main modification to the hcl files was to modify the iso file details for 22.10. Tried 22.04.2 also but faced the same problem.

I’m running this from MacOS (installed using brew version 1.8.7) and running this againist vSphere Server v8 and ESXi v8

Packer can create the template successfully and boots the VM but then gets stuck at:

==> vsphere-iso.linux--server: Waiting for SSH to become available…

Looking at the VM Console, it seems to crash:

I can ping the DHCP assigned IP, SSH is up and running but seemlingly the ubuntu/ubuntu user I’m expecting to be created based on the hcl files was never created.

I manually created the user ubuntu at the console, the script proceeded but failed shortly after:

==> vsphere-iso.linux--server: Connected to SSH!
==> vsphere-iso.linux--server: Provisioning with shell script: ./scripts/setup_2204_withDocker.sh
==> vsphere-iso.linux--server: [sudo] password for : is not in the sudoers file.
==> vsphere-iso.linux--server: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]

Doesn’t solve what’s really going on obviously.

Here’s the referenced crash dump file:
1685927210.490120411.install_fail.crash.txt (1.0 MB)

Any help really appreciated to figure this out! :slight_smile:

Your ssh_username is either empty or it’s :, when it should be ubuntu.
Show me your full packer build command.

Hi, thanks for looking into this :slight_smile:

Here is my build file, the ssh_username is read from a separate variable file that I’m also attaching as there’s nothing sensitive in it. Also including my user-data file.

ubuntu-22.04.pkr.hcl.txt (7.0 KB)

variables.pkrvars100GBdisk-22.10.hcl.txt (1.2 KB)

user-data.txt (1.4 KB)

Thanks :slight_smile:

Can you add this at the top of your hcl file,
run a packer init command on your terminal,
and then run packer build ubuntu-22-04.pkr.hcl again?

packer {
  required_plugins {
    vsphere = {
      version = ">=1.1.2"
      source = "github.com/hashicorp/vsphere"
    }
  }
}