Packer - can't lock file '/var/lock/qemu-server/lock-

SteDec

New Member
Oct 7, 2024
3
1
1
Hi everyone !

I' ve issues with packer and my proxmox cluster.

I would like create a Rocky Linux 9.4 template for starting. After that the idea is to use Terraform with this template.
I'm stuck on packer step.
This is the permissions through my token

Code:
pveum acl list | grep -i "packergrp"
/      | Administrator | group | packergrp | 1 |

My packer version
Code:
packer --version
Packer v1.11.2

Packer use the token for user "packer" who is member of "packergrp" .
This is my hcl code

Code:
packer {
  required_plugins {
    proxmox = {
      version = ">= 1.2.1"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

variable "proxmox_api_url" {
  type = string
}

variable "proxmox_api_token_id" {
  type = string
}

variable "proxmox_api_token_secret" {
  type = string
  sensitive = true
}

variable "ssh_username" {
  type = string
}

variable "ssh_password" {
  type = string
}



source "proxmox" "rocky-linux" {
  proxmox_url               = "${var.proxmox_api_url}"
  username                  = "${var.proxmox_api_token_id}"
  token                     = "${var.proxmox_api_token_secret}"
  insecure_skip_tls_verify  = true

  node                      = "proxmoxve"
  vm_name                   = "rocky-linux-with-ks"
  template_description      = "Rocky Linux avec KS.cfg"

  iso_file                  = "local:iso/Rocky-9.4-x86_64-minimal.iso"
  iso_storage_pool          = "local"
  unmount_iso               = true
  qemu_agent                = true

  scsi_controller           = "virtio-scsi-single"
  cores                     = "4"
  sockets                   = "2"
  memory                    = "4096"

  cpu_type                  = "host"    # CPU type host
  bios                      = "seabios" # SeaBIOS

  disks {
    disk_size               = "20G"
    format                  = "raw"
    storage_pool            = "local-lvm"
    type                    = "scsi"
    io_thread                = true  
  }

  network_adapters {
    model                   = "virtio"
    bridge                  = "vmbr0"
    firewall                = "false"
  }

  boot_command = [  
    "<tab><bs><bs><bs><bs><bs>text nomodeset noapic acpi=off inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
  ]
#"boot_command": "<tab> inst.text inst.ks=https://raw.githubusercontent.com/xxx/xxx/xxx/centos-7.cfg <enter><wait>",
  boot                      = "c"
  boot_wait                 = "15s"
  communicator              = "ssh"

  http_directory            = "./http"  
  http_port_min             = 8098
  http_port_max             = 8098

  ssh_username              = "${var.ssh_username}"
  ssh_password              = "${var.ssh_password}"

  ssh_timeout               = "30m"
  ssh_pty                   = true
  ssh_handshake_attempts    = 15
}

build {
  name    = "rocky-linux-with-ks"
  sources = [
    "source.proxmox.rocky-linux"
  ]
}

I've my kickstart file in http dir and my variables.pkvars.hcl.
Everything is fine exept at the end, especially on stopping VM for create the template.

On pve side I've this

Code:
trying to acquire lock...
TASK ERROR: can't lock file '/var/lock/qemu-server/lock-104.conf' - got timeout

and on packer side

Code:
rocky-linux-with-ks.proxmox.rocky-linux: output will be in this color.

==> rocky-linux-with-ks.proxmox.rocky-linux: Creating VM
==> rocky-linux-with-ks.proxmox.rocky-linux: No VM ID given, getting next free from Proxmox
==> rocky-linux-with-ks.proxmox.rocky-linux: Starting VM
==> rocky-linux-with-ks.proxmox.rocky-linux: Starting HTTP server on port 8098
==> rocky-linux-with-ks.proxmox.rocky-linux: Waiting 15s for boot
==> rocky-linux-with-ks.proxmox.rocky-linux: Typing the boot command
==> rocky-linux-with-ks.proxmox.rocky-linux: Waiting for SSH to become available...
==> rocky-linux-with-ks.proxmox.rocky-linux: Connected to SSH!
==> rocky-linux-with-ks.proxmox.rocky-linux: Stopping VM
==> rocky-linux-with-ks.proxmox.rocky-linux: Error converting VM to template, could not stop: VM quit/powerdown failed
==> rocky-linux-with-ks.proxmox.rocky-linux: Provisioning step had errors: Running the cleanup provisioner, if present...
==> rocky-linux-with-ks.proxmox.rocky-linux: Stopping VM
==> rocky-linux-with-ks.proxmox.rocky-linux: Deleting VM
Build 'rocky-linux-with-ks.proxmox.rocky-linux' errored after 8 minutes 13 seconds: Error converting VM to template, could not stop: VM quit/powerdown failed

I tried
  1. To use a different id : same issue
  2. To update my repo on packer : same
  3. When I tested the code, I had some issues and I stopped many time the code ( CTRL + C ) and the machines have been poweroff, even if my linux work .
I think the problem is on the templating phase.
I check the new version of code here : https://github.com/hashicorp/packer-plugin-proxmox/blob/main/docs/builders/iso.mdx . But elements are missing ( like
iso_storage_pool , umount_iso ... )
Do you have any ideas please ?
 
Hi !

I found the problem,

In my ks.cfg file, I disable acpi ! --> **acpi=off**

This command create my issue, even the shutdown command was stuck in the same way than packer

I remove them and it's work fine !

Have nice day !
 
  • Like
Reactions: vshab