HCL reference examples for ubuntu distributions

Hiall,
Is there somewhere a reference of HCL files for various Ubuntu distributions?
Or at least some example files ?

I spent days to be able to get a valid HCL file in order to create an Ubuntu 18.04.4 VM (using preseed).
Now I want to create an HCL file in order to create an Ubuntu 22.04.5 VM. I thought it would be easier as preseed is replaced by autoinstall/subiquity. But I cannot get something working: packer systematicaly stops after an ssh connection error (while created VM is still running subiquity).

I understood that the boot_command used in HCL file is VERY tightly linked to the version of Ubuntu ISO being used, I spent quite a lot of time finding the correct boot command for each ISO I am using.

It is not clear wether HCL file should do ‘modifyvm --nic1/–nic2’ according to ISO being used.
I tried many different things in my HCL file and in user-data file for Ubuntu 22.04.5, but still have systematicaly packer stopping on ssh error :

 error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

If anyone has hints or links to useful resources on these subjects, I would be grateful

I think most of my problems come from the way I am declaring user password …
In my user-data, I have :
#cloud-config
autoinstall:
version: 1
identity:
hostname: focusdev
username: user
password: ‘$6$PU***********g1’

The password content was generated with: mkpasswd -m sha-512 ‘****’
With stars representing the fixed, short password I want to be set. For some reason it seems it is not the correct syntax because when subiquity is running and I try from host to ssh using known user and password, I get kicked out.

Do you know if there are any restrictions on password length ?

Finaly found the solution: change ssh_port

packer {
  required_version = ">= 1.6.0"
}
source "virtualbox-iso" "jammy" {
  vm_name       = "focusdev"
...
  ssh_port = 2288                   ##ESSENTIAL! packer must not try to ssh until subiquity finished install and rebooted => not port 22 ! Must also be set for sshd in user-data
...
  boot_command = [...

  headless  = true

  vboxmanage = [
    # NIC 1: NAT (PRIMARY interface, default route)
    ["modifyvm", "{{.Name}}", "--nic1", "nat"],
    # NIC 2: host-only (autoinstall files access)
    ["modifyvm", "{{.Name}}", "--nic2", "hostonly"],
    ["modifyvm", "{{.Name}}", "--hostonlyadapter2", "vboxnet0"]
  ]
}
build {
...
1 Like