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

[BUG] Always recreate VM (Windows) #36

Open
HarishHary opened this issue Jul 29, 2020 · 0 comments
Open

[BUG] Always recreate VM (Windows) #36

HarishHary opened this issue Jul 29, 2020 · 0 comments

Comments

@HarishHary
Copy link

HarishHary commented Jul 29, 2020

Describe the bug
Terraform apply on already applied ressources, destroyed them and applied them again. This happens on a windows machines templaces.

To Reproduce

  • terraform apply

Expected behavior

No ressources to create

Screenshots

terraform plan
  # proxmox_virtual_environment_vm.wks must be replaced
-/+ resource "proxmox_virtual_environment_vm" "wks" {
        acpi                    = true
        bios                    = "seabios"
        description             = jsonencode(
            {
                groups = [
                    "wks",
                    "vlan200",
                ]
            }
        )
      ~ id                      = "103" -> (known after apply)
      ~ ipv4_addresses          = [
          - [
              - "10.10.200.7",
            ],
          - [
              - "127.0.0.1",
            ],
        ] -> (known after apply)
      ~ ipv6_addresses          = [
          - [
              - "fe80::c9fb:9478:5bde:486a%6",
            ],
          - [
              - "::1",
            ],
        ] -> (known after apply)
        keyboard_layout         = "en-us"
      ~ mac_addresses           = [
          - "0A:7E:42:B6:F0:FF",
          - "",
        ] -> (known after apply)
        name                    = "wks-vlan200"
      ~ network_interface_names = [
          - "Ethernet",
          - "Loopback Pseudo-Interface 1",
        ] -> (known after apply)
        node_name               = "HKHostSecLab1"
        started                 = true
        tablet_device           = true
        template                = false
        vm_id                   = -1

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

      ~ clone {
            vm_id = 2004
        }

      ~ cpu {
            architecture = "x86_64"
            cores        = 2
          - flags        = [] -> null
            hotplugged   = 0
            sockets      = 1
            type         = "qemu64"
            units        = 4096
        }

      + disk { # forces replacement
          + datastore_id = "local-zfs" # forces replacement
          + file_format  = "qcow2" # forces replacement
          + size         = 40 # forces replacement
        }

      ~ network_device {
            bridge      = "vmbr0"
            enabled     = true
          - mac_address = "0A:7E:42:B6:F0:FF" -> null
            model       = "e1000"
            rate_limit  = 0
            vlan_id     = 200
        }

        operating_system {
            type = "win10"
        }
    }

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

------------------------------------------------------------------------
terraform plan -refresh=false
No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

As you can see, the disk values are not set on the tfstate. Hence recreating it again. Manually changing the tfstate to have the correct values fixes this. There is a problem on getting those values at the end of the ressource creation. Qemu-agents is enabled and working since I can get the ip addresses etc...

Workaround
Use the lifecycle management tool from terraform

lifecycle {
    ignore_changes = [
      disk,
    ]
  }

Best regards,

@HarishHary HarishHary changed the title [BUG] [BUG] Always recreate VM (Windows) Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant