Telmate / terraform-provider-proxmox

Terraform provider plugin for proxmox
MIT License
2.14k stars 517 forks source link

Serial device cannot be removed from VM #1034

Closed maksimsamt closed 1 month ago

maksimsamt commented 4 months ago

System details:

Creating new resources works as expected, serial device is correctly created. Initial config (serial block snippet):

...
resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
...
  serial = {
    id   = 0
    type = "socket"
  }
...
}
...

Decide to remove serial device, by removing serial block from config.

In terraform apply output all looks fine, serial block should be removed and result shows as Apply complete! Resources: 0 added, 1 changed, 0 destroyed.:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # proxmox_vm_qemu.cloud_vm_from_packer_template will be updated in-place
  ~ resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
        id                     = "***/qemu/***"
        name                   = "***"
        tags                   = "***"
        # (65 unchanged attributes hidden)

      - serial {
          - id   = 0 -> null
          - type = "socket" -> null
        }

        # (6 unchanged blocks hidden)
    }

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

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

  Enter a value: yes

proxmox_vm_qemu.cloud_vm_from_packer_template: Modifying... [id=***/qemu/***]
proxmox_vm_qemu.cloud_vm_from_packer_template: Modifications complete after 1s [id=***/qemu/***]
╷
│ Warning: VM needs to be rebooted and automatic_reboot is disabled
│ 
│   with proxmox_vm_qemu.cloud_vm_from_packer_template,
│   on main.tf line 42, in resource "proxmox_vm_qemu" "cloud_vm_from_packer_template":
│   42: resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
│ 
│ One or more parameters are modified that only take effect after a reboot (shutdown & start).
╵

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

After VM shutdown & start serial device still exists:

image

When I try to run terraform apply again, it says that everything is fine and there are no changes:

No changes. Your infrastructure matches the configuration.

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

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

This serial device can only be removed through the Proxmox GUI.

Similar situation is with network device removing https://github.com/Telmate/terraform-provider-proxmox/issues/1027

maksimsamt commented 3 months ago

@Tinyblargon , Maybe it makes sense to make the same scheme as for disks? For example:

...
resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
...
  serials = {
    serial0 = {
        id   = 0
        type = "socket"
    }
    serial1 = {
        id   = 1
        type = "socket"
    }
  }
...
}
...
maksimsamt commented 1 month ago

https://github.com/Telmate/terraform-provider-proxmox/pull/1079

works as expected!