[SOLVED] VM Boot problem when cloning VM using terraform on proxmox

kmonti

New Member
Aug 15, 2024
12
1
3
Hi guys, i have a template created by packer on proxmox 8.4.14

Using source = "telmate/proxmox"

version = "3.0.2-rc01"

i have the following code to perform a clone qm:

Code:
resource "proxmox_vm_qemu" "haproxy3" {
name        = "obsd78haproxy3"
target_node = "pve"
clone       = "openbsd78-tmpl"
full_clone  = true
os_type     = "l26"
cpu {
cores   = 2
sockets = 1
type    = "host"
}
disk {
slot         = "scsi0"
type         = "disk"
storage      = "local"
size         = "5G"
cache        = "none"
discard      = true
replicate    = false
format       = "qcow2"
}
boot        = "order=scsi0;net0"
bootdisk    = "scsi0"
scsihw      = "virtio-scsi-pci"
memory      = 2048
agent       = 0

network {
id     = 0
model  = "virtio"
bridge = "vmbr0"
}
}


^^ this creates qm 121 which is in a bootloop / console flickering mode

Code:
# qm config  121
agent: 0
balloon: 0
bios: seabios
boot: order=scsi0;net0
cicustom: 
ciupgrade: 0
cores: 2
cpu: host
description: Managed by Terraform.
hotplug: network,disk,usb
kvm: 1
memory: 2048
meta: creation-qemu=9.2.0,ctime=1761236505
name: obsd78haproxy3
net0: virtio=BC:24:11:37:D0:B5,bridge=vmbr0
numa: 0
onboot: 0
ostype: other
protection: 0
scsi0: local:121/vm-121-disk-0.qcow2,cache=none,discard=on,replicate=0,size=5G
scsihw: virtio-scsi-pci
smbios1: uuid=fa914240-249d-430b-8cae-4d0d0e39b999
sockets: 1
tablet: 1
vga: serial0
vmgenid: aa0f4eed-323b-4323-825d-a72b17aa7275

123 is cloned from GUI and works correctly.

Code:
# qm config  123
agent: 0
boot: order=scsi0;net0
cores: 2
description: OpenBSD 7.8 x86_64 template built with packer ().
kvm: 1
memory: 1024
meta: creation-qemu=9.2.0,ctime=1761236505
name: nowy
net0: virtio=BC:24:11:C7:09:7B,bridge=vmbr0
numa: 0
onboot: 0
ostype: other
scsi0: local:123/vm-123-disk-0.qcow2,cache=none,discard=on,replicate=0,size=5G
scsihw: virtio-scsi-pci
serial0: socket
smbios1: uuid=6534486c-525e-40f3-98ab-90947d14be60
sockets: 1
vga: serial0
vmgenid: 8af44c60-462d-4ce7-a27f-96d7055d011a

diff between them:

diff -u <(qm config 121) <(qm config 123)
--- /dev/fd/632025-10-23 20:45:00.030311273 +0200
+++ /dev/fd/622025-10-23 20:45:00.031311266 +0200
@@ -1,26 +1,19 @@
agent: 0
-balloon: 0
-bios: seabios
boot: order=scsi0;net0
-cicustom:
-ciupgrade: 0
cores: 2
-cpu: host
-description: Managed by Terraform.
-hotplug: network,disk,usb
+description: OpenBSD 7.8 x86_64 template built with packer (). Username%3A kamil
kvm: 1
-memory: 2048
+memory: 1024
meta: creation-qemu=9.2.0,ctime=1761236505
-name: obsd78haproxy3
-net0: virtio=BC:24:11:37:D0:B5,bridge=vmbr0
+name: nowy
+net0: virtio=BC:24:11:C7:09:7B,bridge=vmbr0
numa: 0
onboot: 0
ostype: other
-protection: 0
-scsi0: local:121/vm-121-disk-0.qcow2,cache=none,discard=on,replicate=0,size=5G
+scsi0: local:123/vm-123-disk-0.qcow2,cache=none,discard=on,replicate=0,size=5G
scsihw: virtio-scsi-pci
-smbios1: uuid=fa914240-249d-430b-8cae-4d0d0e39b999
+serial0: socket
+smbios1: uuid=6534486c-525e-40f3-98ab-90947d14be60
sockets: 1
-tablet: 1
vga: serial0
-vmgenid: aa0f4eed-323b-4323-825d-a72b17aa7275
+vmgenid: 8af44c60-462d-4ce7-a27f-96d7055d011a
i was destroying and recreating it muliple times and it ran once.

Terraform will perform the following actions:


Code:
# proxmox_vm_qemu.haproxy3 will be created
+ resource "proxmox_vm_qemu" "haproxy3" {
+ additional_wait        = 5
+ agent                  = 0
+ agent_timeout          = 90
+ automatic_reboot       = true
+ balloon                = 0
+ bios                   = "seabios"
+ boot                   = "order=scsi0;net0"
+ bootdisk               = "scsi0"
+ ciupgrade              = false
+ clone                  = "openbsd78-tmpl"
+ clone_wait             = 10
+ current_node           = (known after apply)
+ default_ipv4_address   = (known after apply)
+ default_ipv6_address   = (known after apply)
+ define_connection_info = true
+ desc                   = "Managed by Terraform."
+ force_create           = false
+ full_clone             = true
+ hotplug                = "network,disk,usb"
+ id                     = (known after apply)
+ kvm                    = true
+ linked_vmid            = (known after apply)
+ memory                 = 2048
+ name                   = "obsd78haproxy3"
+ onboot                 = false
+ os_type                = "l26"
+ protection             = false
+ reboot_required        = (known after apply)
+ scsihw                 = "virtio-scsi-pci"
+ skip_ipv4              = false
+ skip_ipv6              = false
+ ssh_host               = (known after apply)
+ ssh_port               = (known after apply)
+ tablet                 = true
+ tags                   = (known after apply)
+ target_node            = "pve"
+ unused_disk            = (known after apply)
+ vm_state               = "running"
+ vmid                   = (known after apply)

+ cpu {
+ cores   = 2
+ limit   = 0
+ numa    = false
+ sockets = 1
+ type    = "host"
+ units   = 0
+ vcores  = 0
}

+ disk {
+ backup               = true
+ cache                = "none"
+ discard              = true
+ format               = "qcow2"
+ id                   = (known after apply)
+ iops_r_burst         = 0
+ iops_r_burst_length  = 0
+ iops_r_concurrent    = 0
+ iops_wr_burst        = 0
+ iops_wr_burst_length = 0
+ iops_wr_concurrent   = 0
+ linked_disk_id       = (known after apply)
+ mbps_r_burst         = 0
+ mbps_r_concurrent    = 0
+ mbps_wr_burst        = 0
+ mbps_wr_concurrent   = 0
+ passthrough          = false
+ replicate            = false
+ size                 = "5G"
+ slot                 = "scsi0"
+ storage              = "local"
+ type                 = "disk"
}

+ network {
+ bridge    = "vmbr0"
+ firewall  = false
+ id        = 0
+ link_down = false
+ macaddr   = (known after apply)
+ model     = "virtio"
}

+ smbios (known after apply)
}