hashicorp / packer-plugin-proxmox

Packer plugin for Proxmox Builder
https://www.packer.io/docs/builders/proxmox
Mozilla Public License 2.0
159 stars 70 forks source link

Crash when using multiple "additional_iso_files" #296

Open blk-ole opened 1 day ago

blk-ole commented 1 day ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

I'm trying to build a Windows 2019 image on Proxmox with Packer. As basis I use the templates from Stefan Scherer and converted them to HCL2. This required the usage of two time "additional_iso_files". One for the autounattend.xml + scripts and one for the virtio-driver iso.

Error when building:

==> Some builds didn't complete successfully and had errors:
--> proxmox-iso.win2019-template: unexpected EOF

==> Builds finished but no artifacts were created.
panic: runtime error: index out of range [1] with length 1
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: 
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: goroutine 40 [running]:
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.generateProxmoxDisks({0xc000140a80, 0x1, 0x2?}, {0xc0006ec300, 0x3, 0x2?}, {0x0?, 0x0, 0x2?})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/step_start_vm.go:588 +0x213c
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.(*stepStartVM).Run(0xc0004fc090, {0x11931fc?, 0xc00068e0a0?}, {0x1538568, 0xc0006880f0})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/step_start_vm.go:110 +0x165
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc000688240, {0x15387d0, 0xc00068e0a0}, {0x1538568, 0xc0006880f0})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-sdk@v0.5.4/multistep/basic_runner.go:73 +0x2be
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*DebugRunner).Run(0xc000688210, {0x15387d0, 0xc00068e0a0}, {0x1538568, 0xc0006880f0})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-sdk@v0.5.4/multistep/debug_runner.go:87 +0x3bb
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.(*Builder).Run(0xc00069c000, {0x15387d0, 0xc00068e0a0}, {0x153dc78?, 0xc0006880c0}, {0x152c7c0?, 0xc00089e060}, {0x1538568?, 0xc0006880f0?})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/builder.go:111 +0xeab
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/iso.(*Builder).Run(0xc0000c0000, {0x15387d0, 0xc00068e0a0}, {0x153dc78, 0xc0006880c0}, {0x152c7c0, 0xc00089e060})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/iso/builder.go:47 +0x357
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0xc00003f140, 0x2b2040?, 0xc0002b2020)
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-sdk@v0.5.4/rpc/builder.go:120 +0x1c8
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: reflect.Value.call({0xc00079c300?, 0xc00013a0c8?, 0x13?}, {0x118cd52, 0x4}, {0xc000686ef8, 0x3, 0x3?})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       reflect/value.go:596 +0xce7
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: reflect.Value.Call({0xc00079c300?, 0xc00013a0c8?, 0x0?}, {0xc000122ef8?, 0x0?, 0x0?})
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       reflect/value.go:380 +0xb9
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: net/rpc.(*service).call(0xc00003f640, 0x0?, 0x0?, 0xc000128060, 0xc000140180, 0x0?, {0xf8c460?, 0xc0002b201c?, 0x0?}, {0xf5d5a0, ...}, ...)
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       net/rpc/server.go:382 +0x211
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin: created by net/rpc.(*Server).ServeCodec in goroutine 1
2024/10/25 15:58:29 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64 plugin:       net/rpc/server.go:479 +0x410
2024/10/25 15:58:29 [INFO] (telemetry) ending proxmox-iso.win2019-template
2024/10/25 15:58:29 ui error: Build 'proxmox-iso.win2019-template' errored after 24 seconds 909 milliseconds: unexpected EOF

Reproduction Steps

Build the attached .hcl file

Plugin and Packer version

Packer v1.11.2 packer-plugin-proxmox_v1.2.1_x5.0_linux_amd64

Simplified Packer Buildfile

packer {
  required_plugins {
    proxmox = {
      source  = "github.com/hashicorp/proxmox"
      version = "~> 1"
    }
  }
}

source "proxmox-iso" "win2019-template" {

    #Proxmox Connection Settings
    proxmox_url = "${var.proxmox_api_url}"
    username = "${var.proxmox_api_token_id}"
    token = "${var.proxmox_api_token_secret}"
    insecure_skip_tls_verify = true

    #VM General Settings
    node = "${var.proxmox_node}"
    vm_name = "win2019-template"
    template_description = "Windows Server 2019 Template, no roles installed"

    #WinRM
    communicator = "winrm"
    winrm_password = "${var.winrm_password}"
    winrm_timeout = "${var.winrm_timeout}"
    winrm_username = "${var.winrm_username}"

    #VM Hardware
    cores = 2
    cpu_type = "host"
    sockets = 1
    memory = "${var.memory}"
    os = "win10"
    bios = "seabios"
    qemu_agent = true

    #ISO with virtio driver for windows
    additional_iso_files {
         type = "scsi"
         iso_file = "virtio_win.iso"
         iso_checksum = "${var.virtio_win_checksum}"
         iso_storage_pool = "images"
         unmount = true
    }

    #Loose files for installation; replaces "old" floppy_files
    additional_iso_files {
      cd_files = ["${var.autounattend}", "./scripts/disable-screensaver.ps1", "./scripts/disable-winrm.ps1", "./scripts/enable-winrm.ps1", "./scripts/microsoft-updates.bat", "./scripts/unattend.xml", "./scripts/sysprep.bat", "./scripts/win-updates.ps1"]
      cd_label = "cidata"
      iso_storage_pool = "images"
    }

    #Drive configuration
    disks {...}
    #Network
    network_adapters {...}
    rng0 {...}

    #Boot Iso
    boot_iso {
        type = "scsi"
        iso_file = "${var.iso_file}"
        iso_checksum = "${var.iso_checksum}"
        unmount = true
    }

}

Operating system and Environment details

Proxmox 8.2.7 - Community Edition Client: Arch Linux

Log Fragments and crash.log files

crash.log

fattabbydev commented 12 hours ago

I am hitting this same or a similar bug even without an additional_iso_files block defined. It also occurs when one is defined on my machine.

M2 MacBook Air / macOS Sequoia 15.0.1 Proxmox version: 8.2.7 Packer version: Packer v1.11.2 packer-plugin-proxmox version: v1.2.1

2024/10/25 22:23:00 Starting build run: ubuntu-server.proxmox-iso.proxmox-template
2024/10/25 22:23:00 Running builder: proxmox-iso
2024/10/25 22:23:00 [INFO] (telemetry) Starting builder proxmox-iso.proxmox-template
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: 2024/10/25 22:23:00 using token auth
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: 2024/10/25 22:23:00 No CD files specified. CD disk will not be made.
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: 2024/10/25 22:23:00 No URLs were provided to Step Download. Continuing...
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: 2024/10/25 22:23:00 Mapping Disk to sata0
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: panic: runtime error: index out of range [1] with length 1
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: 
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: goroutine 12 [running]:
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.generateProxmoxDisks({0x14000718680, 0x1, 0x1400043f840?}, {0x1400018c700, 0x1, 0x100d78ae4?}, {0x0?, 0x0, 0x14000405708?})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/step_start_vm.go:588 +0x1a60
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.(*stepStartVM).Run(0x1400046a320, {0x1017133e3?, 0x14000108be0?}, {0x101d6f990, 0x140003ed7d0})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/step_start_vm.go:110 +0x11c
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0x140003ed8f0, {0x101d6fbf8, 0x14000108be0}, {0x101d6f990, 0x140003ed7d0})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-sdk@v0.5.4/multistep/basic_runner.go:73 +0x294
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common.(*Builder).Run(0x14000621800, {0x101d6fbf8, 0x14000108be0}, {0x101d74fd8?, 0x140003ed7a0}, {0x101d63a60?, 0x14000724f60}, {0x101d6f990?, 0x140003ed7d0?})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/common/builder.go:111 +0xbcc
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/iso.(*Builder).Run(0x1400066e000, {0x101d6fbf8, 0x14000108be0}, {0x101d74fd8, 0x140003ed7a0}, {0x101d63a60, 0x14000724f60})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/iso/builder.go:47 +0x2d8
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0x14000726dc0, 0xd674c8?, 0x1400010a4b0)
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  github.com/hashicorp/packer-plugin-sdk@v0.5.4/rpc/builder.go:120 +0x1a0
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: reflect.Value.call({0x140007483c0?, 0x140000b40c8?, 0x13?}, {0x10170cf8b, 0x4}, {0x140008dbef8, 0x3, 0x3?})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  reflect/value.go:596 +0x994
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: reflect.Value.Call({0x140007483c0?, 0x140000b40c8?, 0x0?}, {0x1400050eef8?, 0x0?, 0x0?})
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  reflect/value.go:380 +0x94
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: net/rpc.(*service).call(0x14000726e00, 0x0?, 0x0?, 0x1400063c7f0, 0x14000718d00, 0x0?, {0x101b59d40?, 0x1400010a4ac?, 0x0?}, {0x101b2aa80?, ...}, ...)
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  net/rpc/server.go:382 +0x204
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin: created by net/rpc.(*Server).ServeCodec in goroutine 1
2024/10/25 22:23:00 packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64 plugin:  net/rpc/server.go:479 +0x304
2024/10/25 22:23:00 [INFO] (telemetry) ending proxmox-iso.proxmox-template
2024/10/25 22:23:00 ui error: Build 'ubuntu-server.proxmox-iso.proxmox-template' errored after 3 milliseconds 899 microseconds: unexpected EOF
2024/10/25 22:23:00 ui: 
==> Wait completed after 3 milliseconds 918 microseconds
2024/10/25 22:23:00 machine readable: error-count []string{"1"}
2024/10/25 22:23:00 /Users/$user/.config/packer/plugins/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.2.1_x5.0_darwin_arm64: plugin process exited
2024/10/25 22:23:00 ui error: 
==> Some builds didn't complete successfully and had errors:
2024/10/25 22:23:00 machine readable: ubuntu-server.proxmox-iso.proxmox-template,error []string{"unexpected EOF"}
2024/10/25 22:23:00 ui error: --> ubuntu-server.proxmox-iso.proxmox-template: unexpected EOF
2024/10/25 22:23:00 ui: 
==> Builds finished but no artifacts were created.
2024/10/25 22:23:00 [INFO] (telemetry) Finalizing.
2024/10/25 22:23:00 waiting for all plugin processes to complete...
blk-ole commented 7 hours ago

ok, I think i could figure it out. The error is that the boot_iso_file could not be found on the proxmox machine.

Original iso_file variable, which was giving the errors: ${var.iso_file} = "images:17763.3650.221105-1748.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso"

The correction looks like this now: ${var.iso_file} = "images:iso/17763.3650.221105-1748.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso"

I'm also new to proxmox and first needed to wrap my head around the paths used by the API.

Two points of improved come to mind:

fattabbydev commented 2 hours ago

Interesting, confirming this is the case in my environment as well. I had my iso in the wrong directory on my share relative to where Proxmox was looking. After correcting that I am able to progress so I am unsure if this is actually a bug or just needs better error messaging.