[SOLVED] Provision rocky linux with terraform

raloseq

New Member
May 10, 2025
2
1
3
Hi, im trying to clone existing template of rocky linux with terraform but vm on boot says "proxmox could not read from cdrom (code 0004)" i searched google before posting this and couldn't solve this problem, idk if this is problem with .qcow2 rocky image because with .img extension of ubuntu image i was able to create vm (but with bpg provider) , this is how i create template:
Bash:
qm create 500 --memory 2048 --net0 virtio,bridge=vmbr0
qm importdisk 500 Rocky-9-GenericCloud-Base.latest.x86_64.qcow2 main
qm set 500 --scsihw virtio-scsi-pci --scsi0 main:500/vm-500-disk-0.raw
qm set 500 -ide2 main:cloudinit
qm set 500 --boot c --bootdisk scsi0
qm set 500 --serial0 socket --vga serial0

and this is my terraform file
YAML:
terraform {
  required_providers {
    proxmox= {
        source = "telmate/proxmox"
        version = "3.0.1-rc8"
    }
  }
}

provider "proxmox" {
  pm_api_url = var.pm_api_url
  pm_api_token_id = var.pm_api_token_id
  pm_api_token_secret = var.pm_api_token_secret
  pm_tls_insecure = var.pm_tls_insecure
}

resource "proxmox_vm_qemu" "cloudinit-example" {
  vmid        = 100
  name        = "test-terraform0"
  target_node = "pve"
  agent       = 1
  cores       = 2
  memory      = 4096
  boot        = "order=scsi0;ide2"
  clone       = "VM 500"
  full_clone = true
  vm_state    = "running"
  automatic_reboot = true

  # Cloud-Init configuration
  nameserver = "1.1.1.1 8.8.8.8"
  ipconfig0  = "ip=192.168.1.11/24,gw=192.168.1.1,ip6=dhcp"
  skip_ipv6  = true
  ciuser     = "root"
  cipassword = "root"
  sshkeys    = ""

  serial {
    id = 0
  }

  disks {
    scsi {
      scsi0 {
        disk {
          storage = "main"
          size    = "12G"
        }
      }
    }
    ide {
      ide2 {
        cloudinit {
          storage = "main"
        }
      }
    }
  }

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

im open to change configuration or if u have some tutorials i would be thankfull if u share them with me, but it must be rocky linux
 
After adding scsihw = "virtio-scsi-pci" in terraform file it worked, i don't know why qm set 500 --scsihw virtio-scsi-pci was overrided by something.
 
  • Like
Reactions: waltar