Skip to content

Cloud_init and sysprep CDROMs being detected and destroyed forcing VM reboot #285

@gfenn-newbury

Description

@gfenn-newbury

Nutanix Cluster Information

Terraform Version

  • 0.12.17
  • 0.13.7
  • 0.15.3
  • 1.0.0

Affected Resource(s)

  • nutanix_virtual_machine

Terraform Configuration Files

resource "nutanix_virtual_machine" "vm" {
  count = var.platform == "ahv" && local.os_short_name == "rhe" ? 1 : 0
  name  = infoblox_record_host.host.name
  cluster_uuid = element([for c in flatten(data.nutanix_clusters.clusters[*].entities) :
  c.metadata["uuid"] if c.name == var.cluster], 0)
  description          = var.owner != "" ? "${var.owner} - terraform - ${lookup(data.external.environment.result, "date", formatdate("YYYYMMDD", timestamp()))}" : "${lookup(data.external.environment.result, "owner", "terraform")} - terraform - ${lookup(data.external.environment.result, "date", formatdate("YYYYMMDD", timestamp()))}"
  num_vcpus_per_socket = var.cpus <= local.cpu_max ? var.cpus : local.cpu_max
  num_sockets          = 1
  memory_size_mib      = var.memory <= local.memory_max ? var.memory : local.memory_max

  owner_reference = {
    kind = "user"
    name = data.nutanix_user.user[count.index].user_name
    uuid = data.nutanix_user.user[count.index].id
  }

  nic_list {
    subnet_uuid = data.nutanix_subnet.subnet[count.index].id
  }

  guest_customization_cloud_init_user_data = base64encode(data.template_file.cloudinit_user_data[count.index].rendered)

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = data.nutanix_image.image[count.index].id
    }
    device_properties {
      device_type = "DISK"
      disk_address = {
        adapter_type = "SCSI"
        device_index = "0"
      }
    }
  }

  dynamic "disk_list" {
    iterator = iii
    for_each = var.additional_disks
    content {
      disk_size_mib = iii.value * 1000
    }
  }
  ... (provisioners only beyond this point)
}

Actual Behavior

After initial apply to create the VM, a plan would display the following:

      - disk_list {
          - data_source_reference  = {} -> null
          - disk_size_bytes        = 0 -> null
          - disk_size_mib          = 0 -> null
          - uuid                   = "77ebeb80-c890-4130-90fc-85c14d546819" -> null
          - volume_group_reference = {} -> null

          - device_properties {
              - device_type  = "CDROM" -> null
              - disk_address = {
                  - "adapter_type" = "IDE"
                  - "device_index" = "0"
                } -> null
            }
        }

Steps to Reproduce

  1. Create a nutanix_virtual_machine resource without specifying the creation of a CDROM, but specifying guest_customization_cloud_init_user_data or guest_customization_sysprep
  2. After creation, run terraform plan again
  3. Observe a CDROM is present, which Terraform wants to destroy
  4. Run terraform apply, and observe the VM is rebooted

Important Factors

This has happened using multiple different versions of Terraform, and with provider version 1.1.1 and 1.2.0, all against AOS 5.19.*. This is not present in 5.15 LTS, and we are yet to test 5.20 LTS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.2.2Release 1.2.2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions