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

Machine value not saved in state after first tofu apply for proxmox_virtual_environment_vm resource when clonning #1593

Open
arsensimonyanpicsart opened this issue Oct 14, 2024 · 2 comments
Labels
🐛 bug Something isn't working topic:clone

Comments

@arsensimonyanpicsart
Copy link

arsensimonyanpicsart commented Oct 14, 2024

Describe the bug
When setting the machine value to “pc” in the resource configuration, the first tofu apply does not save the machine value in the state file. Running tofu plan after the first apply still shows changes to set the machine value. After the second tofu apply, the machine value is finally saved to the state.

To Reproduce

  1. Create a resource with the following configuration:
 terraform {
  required_providers {
    proxmox = {
      source  = "bpg/proxmox"
      version = "0.64.0"
    }
    time = {
      source = "hashicorp/time"
    }
  }
}

provider "proxmox" {
  endpoint  = "https://xxx:8006/"
  api_token = "xxx"
  insecure  = true
  ssh {
    agent    = true
    username = "xxx"
  }
}

provider "proxmox" {
  endpoint  = "https://xxx:8006/"
  api_token = "xxx"
  insecure  = true
  ssh {
    agent    = true
    username = "xxx"
    # password = "q]w[ep.69G]"
  }
}

 resource "proxmox_virtual_environment_vm" "vm" {
  name        = "xxx"
  description = "Managed by Terraform"
  pool_id     = "xxx"
  node_name   = "xxx"
  scsi_hardware = "virtio-scsi-single"
  acpi          = true
  bios          = "seabios"
  machine       = "pc"
  boot_order    = ["scsi0"]
  clone {
    vm_id     = 9000
    full      = true
    node_name = "xxx"
  }
  cpu {
    cores   = 1
    sockets = 1
    type    = "host"
  }
  memory {
    dedicated = 4096
  }
  network_device {
    bridge  = "vmbr0"
    vlan_id = 1045
    model   = "virtio"
  }
  disk {
    datastore_id = "Pure-NFS"
    interface    = "scsi0"
    size         = "10"
  }
  vga {
    type   = "std"
    memory = 16
  }
  tablet_device = true
  keyboard_layout = "en-us"
  operating_system {
    type = "l26"
  }
  agent {
    enabled = true
    timeout = "20s"
    trim    = false
    type    = "virtio"
  }
}
  1. Run tofu apply.

  2. Run tofu plan, observe that the machine value still shows as needing to be applied.

  3. Run tofu apply again.

  4. Observe that the machine type is now recorded in the state.

  5. Create a resource '....'

  6. Run '....'

  7. See error

  8. Modify the resource '....'

  9. Run '....'

  10. See error

Please also provide a minimal Terraform configuration that reproduces the issue.

terraform {
  required_providers {
    proxmox = {
      source  = "bpg/proxmox"
      version = "0.64.0"
    }
    time = {
      source = "hashicorp/time"
    }
  }
}

provider "proxmox" {
  endpoint  = "https://xxx:8006/"
  api_token = "xxx"
  insecure  = true
  ssh {
    agent    = true
    username = "xxx"
  }
}

resource "proxmox_virtual_environment_vm" "vm" {
  name        = "xxx"
  description = "Managed by Terraform"
  pool_id     = "xxx"
  node_name   = "xxx"
  scsi_hardware = "virtio-scsi-single"
  acpi          = true
  bios          = "seabios"
  machine       = "pc"
  boot_order    = ["scsi0"]
  clone {
    vm_id     = 9000
    full      = true
    node_name = "xxx"
  }
  cpu {
    cores   = 1
    sockets = 1
    type    = "host"
  }
  memory {
    dedicated = 4096
  }
  network_device {
    bridge  = "vmbr0"
    vlan_id = 1045
    model   = "virtio"
  }
  disk {
    datastore_id = "Pure-NFS"
    interface    = "scsi0"
    size         = "10"
  }
  vga {
    type   = "std"
    memory = 16
  }
  tablet_device = true
  keyboard_layout = "en-us"
  operating_system {
    type = "l26"
  }
  agent {
    enabled = true
    timeout = "20s"
    trim    = false
    type    = "virtio"
  }
}

and the output of terraform|tofu apply.


Expected behavior
I expected the machine value to be saved in the state after the first tofu apply.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox: Clustered
  • Proxmox version: 8.2.7
  • Provider version (ideally it should be the latest version): 0.64.0
  • Terraform/OpenTofu version: OpenTofu 1.8.3
  • OS (where you run Terraform/OpenTofu from): macos sonoma, ubuntu 22
  • Debug logs (TF_LOG=DEBUG terraform apply):
@arsensimonyanpicsart arsensimonyanpicsart added the 🐛 bug Something isn't working label Oct 14, 2024
@bpg bpg changed the title Machine value not saved in state after first tofu apply for proxmox_virtual_environment_vm resource Machine value not saved in state after first tofu apply for proxmox_virtual_environment_vm resource when clonning Oct 15, 2024
@bpg
Copy link
Owner

bpg commented Oct 15, 2024

Similar to #1575

@arsensimonyanpicsart
Copy link
Author

This can be a very frustrating issue when moving to production, as it might require rebooting all your provisioned vm_qemu hosts. We’ve already been impacted by this, with all MongoDB cluster nodes restarting together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working topic:clone
Projects
Status: ☑️ Todo
Development

No branches or pull requests

2 participants