terraform-provider-proxmox
terraform-provider-proxmox copied to clipboard
Machine value not saved in state after first tofu apply for proxmox_virtual_environment_vm resource when clonning
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
- 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"
}
}
-
Run tofu apply.
-
Run tofu plan, observe that the machine value still shows as needing to be applied.
-
Run tofu apply again.
-
Observe that the machine type is now recorded in the state.
-
Create a resource '....'
-
Run '....'
-
See error
-
Modify the resource '....'
-
Run '....'
-
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):
Similar to #1575
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.