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

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

Closed
gfenn-newbury opened this issue Jun 29, 2021 · 2 comments
Labels
1.2.2 Release 1.2.2

Comments

@gfenn-newbury
Copy link
Contributor

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.

@gfenn-newbury
Copy link
Contributor Author

Is there any update on this?

@TheMoves
Copy link

TheMoves commented Nov 1, 2021

Switching from using the resource type of template_file to the built in templatefile for userdata fixed the issue for us - i didn't see anything about a CDROM being the culprit.

@siddharth-nutanix siddharth-nutanix added the 1.2.2 Release 1.2.2 label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.2.2 Release 1.2.2
Projects
None yet
Development

No branches or pull requests

3 participants