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

Initialization settings cannot be cleared when cloning. #1106

Open
benosman opened this issue Mar 9, 2024 · 0 comments
Open

Initialization settings cannot be cleared when cloning. #1106

benosman opened this issue Mar 9, 2024 · 0 comments
Labels
🐛 bug Something isn't working topic:clone

Comments

@benosman
Copy link

benosman commented Mar 9, 2024

Describe the bug
If I create a VM with a Initialization block, such as adding cicustom or ssh keys, and then clone that VM, the initialization settings carry over even if you try to empty them.

To Reproduce

  1. Create a resource for the base vm 'proxmox_virtual_environment_vm.base' with user_data_file_id
  2. Create a resource for the clone vm 'proxmox_virtual_environment_vm.clone' with empty user_data_file_id
  3. Run 'terraform init && terraform apply'
  4. Every apply detects changes to remove the initialization but it does not ever apply
  5. the vm config file in /etc/pve/qemu/ shows the cicustom config same as base

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

resource "proxmox_virtual_environment_file" "user_config" {
  content_type = "snippets"
  datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local"))
  node_name    = data.proxmox_virtual_environment_datastores.example.node_name

  source_raw {
    data = <<EOF
#cloud-config
hostname: terraform-provider-proxmox-example
EOF

    file_name = "terraform-provider-proxmox-example-user-config.yaml"
  }
}

resource "proxmox_virtual_environment_vm" "base" {
  name                   = "base"
  node_name         = "pve"
  started                 = false
   disk {
      interface   = "scsi2"
      size        = 10
      file_format = "raw"
  }

  initialization {
    datastore_id   = "local"
    interface         = "ide2"
    user_data_file_id = proxmox_virtual_environment_file.user_config.id
  }
}

resource "proxmox_virtual_environment_vm" "clone" {
  name                   = "clone"
  node_name         = "pve"
  started                 = false

  clone {
    vm_id = proxmox_virtual_environment_vm.base.vm_id
    full  = true
  }

  initialization {
    datastore_id   = "local"
    interface         = "ide2"
    user_data_file_id = null
  }
}

Expected behavior
Initialization block should be emptied, cicustom removed from config. Apply should detect no changes

  • Single or clustered Proxmox: Single
  • Provider version (ideally it should be the latest version): 0.46.6
  • Terraform version: 1.7.4
  • OS (where you run Terraform from): macos
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
None yet
Development

No branches or pull requests

2 participants