Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabling cdrom after creation is not possible #1672

Open
Deshke opened this issue Dec 11, 2024 · 2 comments
Open

enabling cdrom after creation is not possible #1672

Deshke opened this issue Dec 11, 2024 · 2 comments
Assignees
Labels
🐛 bug Something isn't working

Comments

@Deshke
Copy link

Deshke commented Dec 11, 2024

Describe the bug
enabling cdrom on an active vm does not attach a cdrom drive

To Reproduce
Steps to reproduce the behavior:

  1. Create a new vm with cdrom.enabled = false
  cdrom {
    enabled   = false
    file_id   = ""
    interface = "ide0"
  }
  1. boot
  2. update tf state and set cdrom.enabled = true
  cdrom {
    enabled   = true
    file_id   = "imagestore:iso/ubuntu-24.04.1-live-server-amd64.iso"
    interface = "ide0"
  }

  1. run tofu/terraform plan or apply
    -> no changes get applied

Expected behavior

cdrom changes are applied

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox:
  • Proxmox version: 8.3
  • Provider version (ideally it should be the latest version): 0.68.1
  • Terraform/OpenTofu version:
  • OS (where you run Terraform/OpenTofu from):
  • Debug logs (TF_LOG=DEBUG terraform apply):
OpenTofu v1.8.5
on linux_amd64
+ provider registry.opentofu.org/bpg/proxmox v0.68.1
@bpg
Copy link
Owner

bpg commented Dec 14, 2024

Hey @Deshke 👋🏼

Could you post the full TF output after you apply at step 4?

@bpg bpg added the ⌛ pending author's response Requested additional information from the reporter label Dec 14, 2024
@Deshke
Copy link
Author

Deshke commented Dec 16, 2024

@bpg here you go

tofu create vm cdrom.enabled = false
OpenTofu will perform the following actions:

  # module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_meta_data["test1672"] will be created
  + resource "proxmox_virtual_environment_file" "vm_cloud_init_meta_data" {
      + content_type           = "snippets"
      + datastore_id           = "imagestore"
      + file_modification_date = (known after apply)
      + file_name              = (known after apply)
      + file_size              = (known after apply)
      + file_tag               = (known after apply)
      + id                     = (known after apply)
      + node_name              = "node-pve-general-test-a-1"
      + overwrite              = true
      + timeout_upload         = 1800

      + source_raw {
          + file_name = "test1672_meta.yaml"
          + resize    = 0
        }
    }

  # module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_user_data["test1672"] will be created
  + resource "proxmox_virtual_environment_file" "vm_cloud_init_user_data" {
      + content_type           = "snippets"
      + datastore_id           = "imagestore"
      + file_modification_date = (known after apply)
      + file_name              = (known after apply)
      + file_size              = (known after apply)
      + file_tag               = (known after apply)
      + id                     = (known after apply)
      + node_name              = "node-pve-general-test-a-1"
      + overwrite              = true
      + timeout_upload         = 1800

      + source_raw {
          + data      = <<-EOT
                #cloud-config
                disable_root: false
                users:
                  - name: ubuntu
                    lock_passwd: false
                    shell: /bin/bash
                    plain_text_passwd: ubuntu
                    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
                package_reboot_if_required: true
                package_update: true
                package_upgrade: false
                packages:
                  - qemu-guest-agent
                runcmd:
                  - systemctl enable qemu-guest-agent
                  - systemctl restart qemu-guest-agent ssh
            EOT
          + file_name = "test1672_user_data.yaml"
          + resize    = 0
        }
    }

  # module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"] will be created
  + resource "proxmox_virtual_environment_vm" "vm_template" {
      + acpi                    = true
      + bios                    = "ovmf"
      + boot_order              = [
          + "virtio0",
          + "ide0",
          + "net0",
        ]
      + description             = "bgp/proxmox  https://github.com/bpg/terraform-provider-proxmox/issues/1672 test"
      + id                      = (known after apply)
      + ipv4_addresses          = (known after apply)
      + ipv6_addresses          = (known after apply)
      + keyboard_layout         = "en-us"
      + mac_addresses           = (known after apply)
      + migrate                 = false
      + name                    = "test1672"
      + network_interface_names = (known after apply)
      + node_name               = "node-pve-general-test-a-1"
      + on_boot                 = true
      + protection              = false
      + reboot                  = false
      + scsi_hardware           = "virtio-scsi-single"
      + started                 = true
      + stop_on_destroy         = true
      + tablet_device           = true
      + template                = false
      + timeout_clone           = 1800
      + timeout_create          = 1800
      + timeout_migrate         = 1800
      + timeout_move_disk       = 1800
      + timeout_reboot          = 1800
      + timeout_shutdown_vm     = 1800
      + timeout_start_vm        = 1800
      + timeout_stop_vm         = 300
      + vm_id                   = (known after apply)

      + agent {
          + enabled = true
          + timeout = "15m"
          + trim    = false
          + type    = "virtio"
        }

      + cdrom {
          + enabled   = false
          + file_id   = "none"
          + interface = "ide0"
        }

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

      + disk {
          + aio               = "io_uring"
          + backup            = true
          + cache             = "writethrough"
          + datastore_id      = "vmstore"
          + discard           = "on"
          + file_format       = (known after apply)
          + file_id           = "imagestore:iso/noble-server-cloudimg-amd64.img"
          + interface         = "virtio0"
          + iothread          = true
          + path_in_datastore = (known after apply)
          + replicate         = true
          + size              = 10
          + ssd               = false
        }

      + efi_disk {
          + datastore_id      = "vmstore"
          + file_format       = (known after apply)
          + pre_enrolled_keys = false
          + type              = "2m"
        }

      + initialization {
          + datastore_id      = "vmstore"
          + interface         = "sata0"
          + meta_data_file_id = (known after apply)
          + upgrade           = (known after apply)
          + user_data_file_id = (known after apply)

          + ip_config {
              + ipv4 {
                  + address = "192.168.103.77/22"
                  + gateway = "192.168.100.1"
                }
            }
        }

      + memory {
          + dedicated      = 4096
          + floating       = 0
          + keep_hugepages = false
          + shared         = 0
        }

      + network_device {
          + bridge      = "vmbr0"
          + enabled     = true
          + firewall    = false
          + mac_address = (known after apply)
          + model       = "virtio"
          + mtu         = 1
          + queues      = 0
          + rate_limit  = 0
          + vlan_id     = 100
        }
      + network_device {
          + bridge      = "vmbr0"
          + enabled     = true
          + firewall    = false
          + mac_address = (known after apply)
          + model       = "virtio"
          + mtu         = 1
          + queues      = 2
          + rate_limit  = 0
          + vlan_id     = 20
        }

      + operating_system {
          + type = "l26"
        }

      + serial_device {
          + device = "socket"
        }

      + startup {
          + down_delay = 60
          + order      = -1
          + up_delay   = 60
        }

      + vga {
          + memory = 16
          + type   = "virtio"
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  OpenTofu will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_meta_data["test1672"]: Creating...
module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_user_data["test1672"]: Creating...
module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_meta_data["test1672"]: Creation complete after 4s [id=imagestore:snippets/test1672_meta.yaml]
module.pve.module.virtual_machines.proxmox_virtual_environment_file.vm_cloud_init_user_data["test1672"]: Creation complete after 4s [id=imagestore:snippets/test1672_user_data.yaml]
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Creating...
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Still creating... [10s elapsed]
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Still creating... [20s elapsed]
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Still creating... [30s elapsed]
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Creation complete after 38s [id=100]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

update vm with cdrom.enable

tofu apply with cdrom.enable = true
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Refreshing state... [id=100]

No changes. Your infrastructure matches the configuration.

OpenTofu has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

looks like .cdrom state is never passed down

2024-12-16T10:36:00.108+0100 [WARN]  Provider "registry.opentofu.org/bpg/proxmox" produced an unexpected new value for module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"] during refresh.
      - .tags: was null, but now cty.ListValEmpty(cty.String)
      - .cpu[0].flags: was null, but now cty.ListValEmpty(cty.String)
2024-12-16T10:36:00.117+0100 [WARN]  provider.terraform-provider-proxmox_v0.68.1: unable to require attribute replacement: error="ForceNew: No changes for node_name" tf_provider_addr=registry.terraform.io/bpg/proxmox tf_req_id=6adca952-1669-e859-d218-f35e37a1ceae tf_resource_type=proxmox_virtual_environment_vm tf_rpc=PlanResourceChange @caller=/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/customdiff/force_new.go:32 @module=sdk.helper_schema tf_attribute_path=node_name tf_mux_provider=tf5to6server.v5tov6Server timestamp="2024-12-16T10:36:00.117+0100"
2024-12-16T10:36:00.118+0100 [WARN]  Provider "registry.opentofu.org/bpg/proxmox" produced an invalid plan for module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"], but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .keyboard_layout: planned value cty.StringVal("en-us") for a non-computed attribute
      - .on_boot: planned value cty.True for a non-computed attribute
      - .timeout_reboot: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .tablet_device: planned value cty.True for a non-computed attribute
      - .template: planned value cty.False for a non-computed attribute
      - .protection: planned value cty.False for a non-computed attribute
      - .timeout_move_disk: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_start_vm: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_stop_vm: planned value cty.NumberIntVal(300) for a non-computed attribute
      - .kvm_arguments: planned value cty.StringVal("") for a non-computed attribute
      - .reboot: planned value cty.False for a non-computed attribute
      - .started: planned value cty.True for a non-computed attribute
      - .tags: planned value cty.ListValEmpty(cty.String) for a non-computed attribute
      - .timeout_shutdown_vm: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .machine: planned value cty.StringVal("") for a non-computed attribute
      - .timeout_create: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_clone: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_migrate: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .acpi: planned value cty.True for a non-computed attribute
      - .migrate: planned value cty.False for a non-computed attribute
      - .efi_disk[0].pre_enrolled_keys: planned value cty.False for a non-computed attribute
      - .efi_disk[0].type: planned value cty.StringVal("2m") for a non-computed attribute
      - .serial_device[0].device: planned value cty.StringVal("socket") for a non-computed attribute
      - .cpu[0].sockets: planned value cty.NumberIntVal(1) for a non-computed attribute
      - .cpu[0].affinity: planned value cty.StringVal("") for a non-computed attribute
      - .cpu[0].hotplugged: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .cpu[0].limit: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .cpu[0].numa: planned value cty.False for a non-computed attribute
      - .cpu[0].units: planned value cty.NumberIntVal(1024) for a non-computed attribute
      - .cpu[0].architecture: planned value cty.StringVal("") for a non-computed attribute
      - .cpu[0].flags: planned value cty.ListValEmpty(cty.String) for a non-computed attribute
      - .startup[0].order: planned value cty.NumberIntVal(-1) for a non-computed attribute
      - .memory[0].hugepages: planned value cty.StringVal("") for a non-computed attribute
      - .memory[0].keep_hugepages: planned value cty.False for a non-computed attribute
      - .memory[0].shared: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .memory[0].floating: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .vga[0].clipboard: planned value cty.StringVal("") for a non-computed attribute
      - .agent[0].type: planned value cty.StringVal("virtio") for a non-computed attribute
      - .agent[0].timeout: planned value cty.StringVal("15m") for a non-computed attribute
      - .agent[0].trim: planned value cty.False for a non-computed attribute
      - .network_device[0].enabled: planned value cty.True for a non-computed attribute
      - .network_device[0].firewall: planned value cty.False for a non-computed attribute
      - .network_device[0].disconnected: planned value cty.False for a non-computed attribute
      - .network_device[0].queues: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .network_device[0].rate_limit: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .network_device[0].trunks: planned value cty.StringVal("") for a non-computed attribute
      - .network_device[1].enabled: planned value cty.True for a non-computed attribute
      - .network_device[1].firewall: planned value cty.False for a non-computed attribute
      - .network_device[1].disconnected: planned value cty.False for a non-computed attribute
      - .network_device[1].rate_limit: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .network_device[1].trunks: planned value cty.StringVal("") for a non-computed attribute
2024-12-16T10:36:00.120+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-12-16T10:36:00.121+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.opentofu.org/bpg/proxmox/0.68.1/linux_amd64/terraform-provider-proxmox_v0.68.1 pid=22220

->

qm config 100
acpi: 1
agent: enabled=1,fstrim_cloned_disks=0,type=virtio
balloon: 0
bios: ovmf
boot: order=virtio0;ide0;net0
cicustom: meta=imagestore:snippets/test1672_meta.yaml,user=imagestore:snippets/test1672_user_data.yaml
cores: 2
cpu: cputype=host
cpuunits: 1024
description: bgp/proxmox  https%3A//github.com/bpg/terraform-provider-proxmox/issues/1672 test
efidisk0: vmstore:100/vm-100-disk-0.raw,efitype=2m,pre-enrolled-keys=0,size=128K
ipconfig0: gw=192.168.100.1,ip=192.168.103.77/22
keyboard: en-us
memory: 4096
meta: creation-qemu=9.0.2,ctime=1734341296
name: test1672
net0: virtio=BC:24:11:5A:47:4E,bridge=vmbr0,firewall=0,mtu=1,tag=100
net1: virtio=BC:24:11:C1:30:A4,bridge=vmbr0,firewall=0,mtu=1,queues=2,tag=20
numa: 0
onboot: 1
ostype: l26
protection: 0
sata0: vmstore:100/vm-100-cloudinit.qcow2,media=cdrom
scsihw: virtio-scsi-single
serial0: socket
smbios1: uuid=a67c6418-342e-428b-9954-e322ffa441e8
sockets: 1
startup: up=60,down=60
tablet: 1
template: 0
vga: memory=16,type=virtio
virtio0: vmstore:100/vm-100-disk-1.qcow2,aio=io_uring,backup=1,cache=writethrough,discard=on,iothread=1,replicate=1,size=10G
vmgenid: f07a4b17-3de5-4d8d-8a20-a51e50c3ca0f

adding a cdrom drive in proxmox and checking with tofu plan afterwards

qm config 100
acpi: 1
agent: enabled=1,fstrim_cloned_disks=0,type=virtio
balloon: 0
bios: ovmf
boot: order=virtio0;ide0;net0
cicustom: meta=imagestore:snippets/test1672_meta.yaml,user=imagestore:snippets/test1672_user_data.yaml
cores: 2
cpu: cputype=host
cpuunits: 1024
description: bgp/proxmox  https%3A//github.com/bpg/terraform-provider-proxmox/issues/1672 test
efidisk0: vmstore:100/vm-100-disk-0.raw,efitype=2m,pre-enrolled-keys=0,size=128K
ide0: none,media=cdrom                                                                                             <----- manual cdrom added
ipconfig0: gw=192.168.100.1,ip=192.168.103.77/22
keyboard: en-us
memory: 4096
meta: creation-qemu=9.0.2,ctime=1734341296
name: test1672
net0: virtio=BC:24:11:5A:47:4E,bridge=vmbr0,firewall=0,mtu=1,tag=100
net1: virtio=BC:24:11:C1:30:A4,bridge=vmbr0,firewall=0,mtu=1,queues=2,tag=20
numa: 0
onboot: 1
ostype: l26
protection: 0
sata0: vmstore:100/vm-100-cloudinit.qcow2,media=cdrom
scsihw: virtio-scsi-single
serial0: socket
smbios1: uuid=a67c6418-342e-428b-9954-e322ffa441e8
sockets: 1
startup: up=60,down=60
tablet: 1
template: 0
vga: memory=16,type=virtio
virtio0: vmstore:100/vm-100-disk-1.qcow2,aio=io_uring,backup=1,cache=writethrough,discard=on,iothread=1,replicate=1,size=10G
vmgenid: f07a4b17-3de5-4d8d-8a20-a51e50c3ca0f
module.pve.module.virtual_machines.proxmox_virtual_environment_vm.vm_template["test1672"]: Refreshing state... [id=100]state... [id=101]

No changes. Your infrastructure matches the configuration.

OpenTofu has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

@bpg bpg removed the ⌛ pending author's response Requested additional information from the reporter label Dec 18, 2024
@bpg bpg self-assigned this Dec 18, 2024
@bpg bpg moved this from 📥 Inbox to ☑️ Todo in terraform-provider-proxmox Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
Status: ☑️ Todo
Development

No branches or pull requests

2 participants