Newbie -- "packer build ubuntu.json" reboots continually

I have VirtualBox 5.2.44 installed on a freebsd 11.3-RELEASE p6 system.
If I run VB and create a new ubuntu 18.04.5 VM from a local iso image,
it starts up fine (although there may be ssh issues).
However, if I run packer to build a system from the same iso image,
the install media boots and goes through the configuration process ok;
after the last question asking if I want to install some popular server environments (no), when I tell it to continue it starts the install process, fetches some updates I think (but doesn’t get too far compared to the successful build) then it reboots and goes through the whole configuration question process again… and again…

The last thing I see before reboot is something about
"Sorry, there was a problem completing the installation…
"Gathering information…

The packer tty session is not helpful, as it shows nothing after the configuration process starts:

$ packer build ubuntu-18-04.json

==> virtualbox-iso: Retrieving Guest additions

==> virtualbox-iso: Retrieving ISO
==> virtualbox-iso: Trying file:///hd2/Downloads/Ubuntu/ubuntu-18.04.5-live-server-amd64.iso

=> /hd2/Downloads/Ubuntu/ubuntu-18.04.5-live-server-amd64.iso
==> virtualbox-iso: Starting HTTP server on port 8102
==> virtualbox-iso: Creating virtual machine…
==> virtualbox-iso: Creating hard drive…
==> virtualbox-iso: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 2322)
==> virtualbox-iso: Executing custom VBoxManage commands…
virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1599079865 --memory 1536
virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1599079865 --cpus 1
==> virtualbox-iso: Starting the virtual machine…
==> virtualbox-iso: Waiting 10s for boot…
==> virtualbox-iso: Typing the boot command…
==> virtualbox-iso: Using ssh communicator to connect: 127.0.0.1
==> virtualbox-iso: Waiting for SSH to become available…

The above “Waiting for SSH to become available…” is the last thing I see in the packer xterm; it preceeds all install / configuration questions.

My .json file:
(I removed provisioners and post-processors, made no difference)

{
“builders”: [
{
“boot_command”: [
“”,
“”,
“”,
“”,
“/install/vmlinuz”,
" auto",
" console-setup/ask_detect=false",
" console-setup/layoutcode=us",
" console-setup/modelcode=pc105",
" debconf/frontend=noninteractive",
" debian-installer=en_US.UTF-8",
" fb=false",
" initrd=/install/initrd.gz",
" kbd-chooser/method=us",
" keyboard-configuration/layout=USA",
" keyboard-configuration/variant=USA",
" locale=en_US.UTF-8",
" netcfg/get_domain=vm",
" netcfg/get_hostname=vagrant",
" grub-installer/bootdev=/dev/sda",
" noapic",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user preseed_path}}",
" – ",
“”
],
“boot_wait”: “10s”,
“disk_size”: “{{user disk_size}}”,
“guest_os_type”: “Ubuntu_64”,
“hard_drive_interface”: “sata”,
“headless”: “{{ user headless }}”,
“http_directory”: “http”,
“iso_checksum”: “{{user iso_checksum_type}}:{{user iso_checksum}}”,
“iso_urls”: [
“file:///hd2/Downloads/Ubuntu/ubuntu-18.04.5-live-server-amd64.iso”,
“{{user mirror}}/{{user mirror_directory}}/{{user iso_name}}”
],
“output_directory”: “…/…/builds/packer-{{user template}}-virtualbox”,
“shutdown_command”: “echo ‘vagrant’ | sudo -S shutdown -P now”,
“ssh_password”: “vagrant”,
“ssh_port”: 22,
“ssh_timeout”: “10000s”,
“ssh_username”: “vagrant”,
“type”: “virtualbox-iso”,
“vboxmanage”: [
[
“modifyvm”,
“{{.Name}}”,
“–memory”,
“{{ user memory }}”
],
[
“modifyvm”,
“{{.Name}}”,
“–cpus”,
“{{ user cpus }}”
]
]
}
],
“variables”: {
“cpus”: “1”,
“disk_size”: “10000”,
“headless”: “”,
“iso_checksum”: “3756b3201007a88da35ee0957fbe6666c495fb3d8ef2e851ed2bd1115dc36446”,
“iso_checksum_type”: “sha256”,
“iso_name”: “ubuntu-18.04.5-live-server-amd64.iso”,
“memory”: “1536”,
“mirror”: “http://releases.ubuntu.com/”,
“mirror_directory”: “18.04.5/”,
“template”: “ubuntu-18.04.05-live-server-amd64.iso”,
“version”: “TIMESTAMP”,
“vm_description”: “packer-ubuntu 18.04.05”,
“vm_version”: “18.04.5”
}
}

The log is no more helpful:
00:00:00.792440 NAT: ICMP/ping not available (could not open ICMP socket, error VERR_ACCESS_DENIED)
00:00:00.799901 NAT: Guest address guess set to 10.0.2.15 by initialization

00:00:00.800106 NAT: Set redirect TCP 127.0.0.1:3531 -> 0.0.0.0:22

00:00:00.812237 Changing the VM state from ‘CREATING’ to ‘CREATED’

00:00:00.815830 Changing the VM state from ‘CREATED’ to ‘POWERING_ON’

00:00:00.815937 Changing the VM state from ‘POWERING_ON’ to ‘RUNNING’

00:00:03.317539 VMMDev: Guest Log: BIOS: Booting from CD-ROM…

00:00:23.342747 NAT: Link up

00:00:29.585079 NAT: DHCP offered IP address 10.0.2.15
00:00:29.585278 NAT: DHCP offered IP address 10.0.2.15
00:00:52.506263 NAT: Old socket recv size: 79KB
00:00:52.506286 NAT: Old socket send size: 79KB

but then nothing while the system boots and configures.

Any ideas what I’m doing wrong?
Is there a way to get VB to dump the packer equivalent to create a vm when one uses the vb gui?

It could be that the unable to ssh is the problem.

Packer thinks it “failed” as it was unable to ssh into the vm. (I think)

I don’t think it’s packer that failed; it’s the VM finishing its startup process.

However… Ideas for how to track down why it failed? Since the VM is set up in virtualbox, which has its own NAT network, I’m at a loss for how to proceed. The .json specifies an ssh_username and ssh_password. Near the end of the configuration the ubuntu vm asks whether or not to install ssh, which I answered affirmatively. The network seems to work, as it fetches updates during the install. Is there a way to capture the screen output from the install process? It doesn’t seem to be written to VBox.log.
I took a screenshot of the VM before it rebooted but there is a big error box in the middle which obscures much of the relevant information, but what I can see is:
Running command [‘udevadm’, ‘settle’] with allowed return codes [0] (capture=False)
TIMED subp([‘udevadm’, ‘settle’]): 0.011
Running command [‘umount’, ‘/target/sys’] with allowed return codes [0]
Running command [‘umount’, ‘/target/proc’] with allowed return codes [0]
Running command [‘umount’, ‘/target/dev’] with allowed return codes [0]
finish: cmd-install/stage-curthooks/001-configure-apt/cmd-in-target: FAIL: curtin command in-target
Stderr: ‘’
Running command [‘uname’, ‘-a’] with allowed return codes [0]
Running c Stuff in blank space obscurred by error box
Traceback "
File "
"/snap/su "
304, in "
await "
File "/ "
decorated "
retur "
File "
"/snap/su "
281, in c "
self.logged_command(curtin_cmd, check=True)
File “/snap/subiquity/1966/lib/python3.6/site-packages/subiquitycore/utils.py”, line 85, in arun_command
raise subprocess.CalledProcessError(proc.returncode, cmd)
subprocess.CalledProcessError: Command ‘[systemd-cat’, ‘–level-prefix=false’;
‘–identifier=curtin_log.1521’, ‘/snap/subiquity/1966/usr/bin/python3’, ‘-m’, ‘curtin’,
‘–showtrace’, ‘-c’, ‘/var/log/installer/subiquity-curtin-install.conf’, ‘install’]’ returned non-zero exit status 3.

If I run with PACKER_LOG=1 packer build -debug ubuntu-18-04.json, when it gets to the step where it prints:
Pausing after run of step “StepRun”. Press Enter to continue.
At this point the VM window comes up and it auto-completes up to the point where it asks for guided storage or use the entire disk. It sits there waiting. But when I hit in response to the “Pause after StepRun” it continues with
==> virtualbox-iso: Waiting 10s for boot…
==> virtualbox-iso: Typing the boot command…
followed by a bunch of VBoxManage commands which look like they had already previously been sent to start the vm.
then:
==> virtualbox-iso: Pausing after run of step 'boot_command:
After I hit (VM is still waiting for disk config type selection),
==> virtualbox-iso: Pausing after run of step ‘StepTypeBootCommand’
After I hit
==> virtualbox-iso: Using ssh communicator to connect: 127.0.0.1
2020/09/05 13:02:33 packer-builder-virtualbox-iso plugin: [INFO] Waiting for SSH, up to timeout: 16m40s
==> virtualbox-iso: Waiting for SSH to become available…

If I then complete the VM config sequence, the packer invoke continues with:

packer-builder-virtualbox-iso plugin: [INFO] Attempting SSH connection to 127.0.0.1:3892…
packer-builder-virtualbox-iso plugin: [DEBUG] reconnecting to TCP connection for SSH
packer-builder-virtualbox-iso plugin: [DEBUG] handshaking with SSH
packer-builder-virtualbox-iso plugin: [DEBUG] SSH handshake err: ssh: handshake failed: EOF

This is repeated over and over, and continues even after the VM has rebooted and started its configuration questions again.

At the start of the run I see the error:
“==> virtualbox-iso: Cannot find “Default Guest Additions ISO” in vboxmanage output (or it is empty)”
It then goes on to download them, so I presume that is not the problem.
However, I do have the additions installed; so it’s not clear to me why it can’t find them. The files installed are in numerous places:
virtualbox-ose-additions-5.2.44:
/boot/modules/vboxguest.ko
/boot/modules/vboxvfs.ko
/usr/local/bin/VBoxClient
/usr/local/bin/VBoxClient-all
/usr/local/etc/rc.d/vboxguest
/usr/local/etc/rc.d/vboxservice
/usr/local/etc/xdg/autostart/vboxclient.desktop
/usr/local/lib/pam_vbox.so
/usr/local/lib/xorg/modules/drivers/vboxvideo_drv.so
/usr/local/lib/xorg/modules/input/vboxmouse_drv.so
/usr/local/sbin/VBoxControl
/usr/local/sbin/VBoxService
/usr/local/sbin/mount_vboxvfs
/usr/local/share/autostart/vboxclient.desktop
/usr/local/share/licenses/virtualbox-ose-additions-5.2.44/GPLv2
/usr/local/share/licenses/virtualbox-ose-additions-5.2.44/LICENSE
/usr/local/share/licenses/virtualbox-ose-additions-5.2.44/catalog.mk