I am trying to create a Proxmox VM template using Packer. However I am getting a Proxmox error saying Build 'proxmox' errored: Error converting VM to template, could not stop: VM quit/powerdown failed - got timeout
.
According to the Proxmox GUI, the VM produces this error during shutdown (status error) but it has no problems stopping (status OK).
I have tried installing and enabling qemu-guest-agent
in the preseeding of the Debian OS.
I have tried installing and starting acpid
and acpi-support
in the preseeding of the Debian OS.
Thank you for your time. All ideas and suggestions are appreciated.
Here is the Packer file I am trying to build:
{
"builders": [
{
"type": "proxmox",
"proxmox_url": "https://192.111.1.108:8006/api2/json",
"insecure_skip_tls_verify": true,
"username": "root@pam",
"password": "foobar",
"vm_name": "pm-prov",
"vm_id": "200",
"node": "pve",
"os": "l26",
"iso_file": "local:iso/debian-10.4.0-amd64-netinst.iso",
"ssh_username": "root",
"ssh_password": "foobar",
"qemu_agent": false,
"memory": "2048",
"communicator": "none",
"scsi_controller": "virtio-scsi-pci",
"network_adapters": [
{
"model": "virtio",
"bridge": "vmbr0"
}
],
"disks": [
{
"type": "scsi",
"disk_size": "32G",
"storage_pool": "local-lvm",
"storage_pool_type": "lvm"
}
],
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=preseed_url <wait>",
"debian-installer=en_US.UTF-8 <wait>",
"auto <wait>",
"locale=en_US.UTF-8 <wait>",
"kbd-chooser/method=us <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
"netcfg/get_hostname=debian_proxmox_hostname <wait>",
"netcfg/get_domain=.local <wait>",
"fb=false <wait>",
"debconf/frontend=noninteractive <wait>",
"console-setup/ask_detect=false <wait>",
"console-keymaps-at/keymap=us <wait>",
"grub-installer/bootdev=/dev/sda <wait>",
"<enter><wait>"
]
}
]
}
Here is the preseed config that is its running:
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/get_ipaddress string 192.168.1.42
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.1.1
d-i netcfg/get_nameservers string 192.168.1.1
d-i netcfg/confirm_static boolean true
d-i netcfg/get_hostname string debian-proxmox
d-i netcfg/get_domain string localdomain
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i passwd/root-password password foobar500
d-i passwd/root-password-again password foobar500
d-i passwd/user-fullname string ops
d-i passwd/username string ops
d-i passwd/user-password password foobar500
d-i passwd/user-password-again password foobar500
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
d-i clock-setup/ntp boolean true
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string debian
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/disk string /dev/sda
d-i partman-auto/choose_recipe select boot-lvm
d-i partman-auto/expert_recipe string \
boot-lvm :: \
500 500 500 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
2048 2048 200% linux-swap \
$lvmok{ } \
lv_name{ swap } in_vg { debian } \
$primary{ } \
method{ swap } format{ } \
. \
2048 2048 2048 ext4 \
$lvmok{ } \
lv_name{ tmp } in_vg { debian } \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /tmp } \
. \
4000 4096 4096 ext4 \
$lvmok{ } \
lv_name{ var_log } in_vg { debian } \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /var/log } \
. \
8192 8192 -1 ext4 \
$lvmok{ } \
lv_name{ root } in_vg { debian } \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
.
d-i partman-md/device_remove_md boolean true
d-i partman-basicfilesystems/no_mount_point boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
tasksel tasksel/first multiselect standard, ssh-server
d-i preseed/late_command string \
in-target rm -rf /var/lib/apt/lists ; \
in-target apt-get update ; \
in-target apt-get -y upgrade ; \
in-target apt-get install qemu-guest-agent -y ; \
in-target apt-get install acpid -y ; \
in-target apt-get install acpi-support -y ; \
in-target systemctl start acpid ; \
in-target systemctl start acpi-support ; \
in-target systemctl enable qemu-guest-agent
d-i pkgsel/include string htop
d-i pkgsel/upgrade select full-upgrade
popularity-contest popularity-contest/participate boolean false
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string /dev/sda
d-i finish-install/reboot_in_progress note
Here is the error in the terminal:
2020/06/25 14:35:11 packer-builder-proxmox plugin: [INFO] communicator disabled, will not connect
2020/06/25 14:35:11 packer-builder-proxmox plugin: Unable to load communicator config from state to populate provisionHookData
2020/06/25 14:35:11 packer-builder-proxmox plugin: Running the provision hook
==> proxmox: Stopping VM
2020/06/25 14:38:18 packer-builder-proxmox plugin: Unable to load communicator config from state to populate provisionHookData
==> proxmox: Error converting VM to template, could not stop: VM quit/powerdown failed - got timeout
==> proxmox: Provisioning step had errors: Running the cleanup provisioner, if present...
==> proxmox: Stopping VM
==> proxmox: Deleting VM
2020/06/25 14:38:23 [INFO] (telemetry) ending proxmox
2020/06/25 14:38:23 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/06/25 14:38:23 machine readable: proxmox,error []string{"Error converting VM to template, could not stop: VM quit/powerdown failed - got timeout"}
==> Builds finished but no artifacts were created.
Build 'proxmox' errored: Error converting VM to template, could not stop: VM quit/powerdown failed - got timeout
2020/06/25 14:38:23 [INFO] (telemetry) Finalizing.
==> Some builds didn't complete successfully and had errors:
--> proxmox: Error converting VM to template, could not stop: VM quit/powerdown failed - got timeout
==> Builds finished but no artifacts were created.
2020/06/25 14:38:23 waiting for all plugin processes to complete...
2020/06/25 14:38:23 /home/linuxbrew/.linuxbrew/Cellar/packer/1.6.0/bin/packer: plugin process exited
I've run into this exact error. Debian 11 will not shut down properly with /sbin/shutdown (which the qemu guest agent calls) without
dbus
.To fix, add
dbus
to your preseed file (or however you are installing packages during build):If that isn't an option, you can use the following script:
This will check the last 20 lines of the packer log, and if it detects the error with converting a VM to template, will stop the debian 11 VM, convert it to a template, and remove the disk drive.
If it can be of help... I've found a similar issue with a qemu / KVM builder. My problem was that the instalation process was stuck showing an error to be accepted. My solution was to connect with a viewer to see the screen. In my case the builder opens a port to connect with VNC...
Another thing to test is increasing the waiting time, I've found that the process spend more than 1 hour to generate a the resulting iso. To accelerate a little this process try to increase the memory and CPU.
Regards!