Packer timeout with Proxmox VE because the VM don't start on disk

Hello,

I use Terraform to deploy VMs on Proxmox VE server, but, presently, I can’t create a PVE template with Packer.
I receive a Packer timeout because my VM can’t boot on disk:

root@proxmox-1:~/git/packer-proxmox# packer build -var pve_username="terraform@pve" -var pve_password="password" -var pve_url="https://proxmox-1:8006/api2/json" centos-7.json 
proxmox-iso: output will be in this color.

==> proxmox-iso: Creating VM
==> proxmox-iso: Starting VM
==> proxmox-iso: Starting HTTP server on port 8284
==> proxmox-iso: Waiting 10s for boot
==> proxmox-iso: Typing the boot command
==> proxmox-iso: Waiting for SSH to become available...
[ 30 minutes laters]
==> proxmox-iso: Timeout waiting for SSH.
==> proxmox-iso: Stopping VM
==> proxmox-iso: Deleting VM
Build 'proxmox-iso' errored after 30 minutes 21 seconds: Timeout waiting for SSH.

==> Wait completed after 30 minutes 21 seconds

==> Some builds didn't complete successfully and had errors:
--> proxmox-iso: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.

It’s weird, because some weeks ago, I don’t have issue to create my PVE template.
I don’t understand why I can’t create my Packer template on the Proxmox VE.

My configuration:

root@proxmox-1:~# pveversion --v
proxmox-ve: 6.3-1 (running kernel: 5.4.78-1-pve)
pve-manager: 6.3-2 (running version: 6.3-2/22f57405)
pve-kernel-5.4: 6.3-2
pve-kernel-helper: 6.3-2
pve-kernel-5.4.78-1-pve: 5.4.78-1
pve-kernel-5.4.73-1-pve: 5.4.73-1
pve-kernel-5.4.34-1-pve: 5.4.34-2
ceph-fuse: 12.2.11+dfsg1-2.1+b1
corosync: 3.0.4-pve1
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.16-pve1
libproxmox-acme-perl: 1.0.5
libproxmox-backup-qemu0: 1.0.2-1
libpve-access-control: 6.1-3
libpve-apiclient-perl: 3.1-1
libpve-common-perl: 6.3-1
libpve-guest-common-perl: 3.1-3
libpve-http-server-perl: 3.0-6
libpve-storage-perl: 6.3-2
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve4
lxc-pve: 4.0.3-1
lxcfs: 4.0.3-pve3
novnc-pve: 1.1.0-1
proxmox-backup-client: 1.0.5-1
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.4-3
pve-cluster: 6.2-1
pve-container: 3.3-1
pve-docs: 6.3-1
pve-edk2-firmware: 2.20200531-1
pve-firewall: 4.1-3
pve-firmware: 3.1-3
pve-ha-manager: 3.1-1
pve-i18n: 2.2-2
pve-qemu-kvm: 5.1.0-7
pve-xtermjs: 4.7.0-3
qemu-server: 6.3-1
smartmontools: 7.1-pve2
spiceterm: 3.1-1
vncterm: 1.6-2
zfsutils-linux: 0.8.5-pve1

root@proxmox-1:~# packer version
Packer v1.6.5

my packer build configuration:

{
  "variables": {
	"pve_username": "",
	"pve_password": "",
	"pve_url": ""
  },
  "builders": [
	{
	  "type": "proxmox-iso",
	  "proxmox_url": "{{ user `pve_url`}}",
	  "insecure_skip_tls_verify": true,
	  "username": "{{user `pve_username`}}",
	  "password": "{{user `pve_password`}}",

	  "node": "proxmox-1",
	  "pool": "pool0",

	  "vm_name": "packer-centos7",
	  "vm_id": 9000,
	  "memory": 4096,
	  "sockets": 1,
	  "cores": 4,
	  "cpu_type": "host",
	  "os": "l26",
	  "cloud_init": true,
	  "cloud_init_storage_pool": "local-lvm",
	  "qemu_agent": true,
	  "disable_kvm": false,
	  "onboot": false,
	  "network_adapters": [
		{
		  "model": "virtio",
		  "bridge": "vmbr0",
		  "firewall": false
		}
	  ],
	  "scsi_controller": "virtio-scsi-single",
	  "disks": [
		{
		  "type": "scsi",
		  "disk_size": "32G",
		  "storage_pool": "local-lvm",
		  "storage_pool_type": "lvm",
		  "format": "raw"
		}
	  ],

	  "iso_file": "local:iso/CentOS-7-x86_64-DVD-2009.iso",
	  "http_directory": "centos7",
	  "boot_wait": "10s",
	  "boot_command": [
		"<tab> ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
	  ],

	  "ssh_username": "root",
	  "ssh_timeout": "30m",
	  "ssh_password": "password",

	  "unmount_iso": true,
	  "template_name": "centos-7-template",
	  "template_description": "CentOS 7 Template, generated on {{ isotime \"2006-01-02T15:04:05Z\" }}"
	}
  ],
  "provisioners": [
	{
	  "type": "shell",
	  "script": "centos7/init.sh",
	  "execute_command": "chmod +x {{ .Path }}; {{ .Path }}"
	},
	{
	  "type": "file",
	  "direction": "upload",
	  "source": "cloud-init",
	  "destination": "/etc/cloud"
	}
  ]
}

my kickstart file:

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard us
# Root password
rootpw --plaintext password
# System language
lang en_US.UTF-8
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# Accept Eula
eula --agreed

# Firewall configuration
firewall --enabled --ssh
# Network information
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network --hostname=centos7-template.my-domain.tld
# Suppress the Unsupported Hardware Detected alert
unsupported_hardware
# System services
services --enabled=NetworkManager,sshd
# Reboot after installation
reboot
# Disable the firstboot wizard
firstboot --disabled
# System timezone
timezone Asia/Tokyo --isUtc --ntpservers=192.168.0.1
# User
user --name=centos --groups=wheel --plaintext --password=password --gecos="centos"
# System bootloader configuration
bootloader --location=mbr --append=" crashkernel=auto" --boot-drive=sda
# Partition
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

%packages
@base
@core
%end

Packer create a lvm volume:

root@proxmox-1:~# lvs
  LV             VG  Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data           pve twi-aotz-- <181.18g             1.42   0.96                            
  root           pve -wi-ao----   69.50g                                                    
  swap           pve -wi-ao----    8.00g                                                    
  vm-100-disk-0  pve Vwi-a-tz--   32.00g data        5.04                                   
  vm-9000-disk-0 pve Vwi-aotz--   32.00g data        2.99

I see that the Packer VM to reboot on cdrom after the installation, but it no boot on the disk… when I force remove the cdrom, the VM doesn’t boot on disk too.

When I reset the Packer VM, and I use the Rescue CentOS system and I can see the correct partition configuration.

Thanks for you help.

Best regards,
pazpop.

Ok, during the installation, I checked the VM configuration in the webgui, and the boot order are not correct. So, after the installation, I turned off the VM, I updated the boot order, and the VM boot on the disk!

When I use the nightly Packer version (Packer v1.6.6-dev) and when I add "boot": "order=scsi0;ide2" in my builder file, the boot order are correct.

Source: https://github.com/hashicorp/packer/issues/10252#issuecomment-731231284