Proxmox & Packer: VM quit/powerdown failed during a Packer build. Anyone have any ideas why?

eddingston

New Member
Jun 26, 2020
2
0
1
34
Hello,

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 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
 
you've set "qemu_agent": false but you need "qemu_agent": true and of course "qemu-guest-agent" needs to be installed in OS

Thank you for your reply.

When "qemu_agent": true , I run into another roblem. I actually install and enable quem-guest-agent in the preseeding of this Debian 10 OS.

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

However since the OS is being set up for the first time, it seems that even though I install quem-guest-agent, it is not recognized by Proxmox before a VM restart. I've come to this conclusion from looking at the VM summary in the GUI which states IPs: Guest Agent not running and from getting the error below.

2020/06/26 09:02:06 packer-builder-proxmox plugin: Unable to load communicator config from state to populate provisionHookData ==> proxmox: Error converting VM to template, could not stop: can't lock file '/var/lock/qemu-server/lock-200.conf' - got timeout ==> proxmox: Provisioning step had errors: Running the cleanup provisioner, if present... ==> proxmox: Stopping VM ==> proxmox: Error stopping VM. Please stop and delete it manually: can't lock file '/var/lock/qemu-server/lock-200.conf' - got timeout 2020/06/26 09:02:42 [INFO] (telemetry) ending proxmox 2020/06/26 09:02:42 machine readable: error-count []string{"1"} ==> Some builds didn't complete successfully and had errors: 2020/06/26 09:02:42 machine readable: proxmox,error []string{"Error converting VM to template, could not stop: can't lock file '/var/lock/qemu-server/lock-200.conf' - got timeout"} ==> Builds finished but no artifacts were created. 2020/06/26 09:02:42 [INFO] (telemetry) Finalizing. Build 'proxmox' errored: Error converting VM to template, could not stop: can't lock file '/var/lock/qemu-server/lock-200.conf' - got timeout ==> Some builds didn't complete successfully and had errors: --> proxmox: Error converting VM to template, could not stop: can't lock file '/var/lock/qemu-server/lock-200.conf' - got timeout ==> Builds finished but no artifacts were created. 2020/06/26 09:02:43 waiting for all plugin processes to complete... 2020/06/26 09:02:43 /home/linuxbrew/.linuxbrew/Cellar/packer/1.6.0/bin/packer: plugin process exited

I believe this error is happening because Proxmox is expecting a qemu-guest-agent to be running, however it does not detect a running agent therefore it produces this error somehow. The agent does start after the VM is restarted.

Please let me know if you have any ideas. Thank you.
 
I don't have much experience with preseed but I'm using following and this is working in my case (without any systemctl magic):

Code:
# Software Selections
tasksel  tasksel/first            multiselect  ssh-server minimal
d-i      pkgsel/include           string       lsof strace openssh-server qemu-guest-agent

also after debian is installed vm will be rebooted by the installer itself - so the service should be started - if not then this is the problem you need to debug...
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!