hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
612 stars 449 forks source link

Needing help with pull request for vapp_transport #2242

Open wvanderwaal-iqmessenger opened 1 month ago

wvanderwaal-iqmessenger commented 1 month ago

Community Guidelines

Description

Hello,

I'm working on a pull request to make vapp_transport accessible from Terraform, however I'm stuck on an issue. I've made a public fork with a branch "feature-vapp_transport" that contains a commit of my current progress.

The possible values for vapp_transport are: "iso" and "com.vmware.guestInfo", this works fine without issue setting these values. However, when you clear vapp_transport of all values, the values will remain the same. This is to be expected, since the documentation of govmomi type says that the list must contains a single empty string element to reset the value.

But when I do this, the value is converted to 'null' and no action is taken, everything stays the same. No matter how much I force this change in the code, testing by setting the value directly to a list with a single empty string value, nothing has worked.

Is there something I'm overlooking? Since my believe is now that somewhere down the line the list with a single empty string will always be converted to list with a null value, since the value of vapp_transport don't change.

Hopefully you can help me with my question of sending a list with a single empty string.

Use Case(s)

Making vapp_transport controllable from Terraform requires no longer to edit the XML of the image. Once OVF is used, it will allow to both enable environment transport, and setting the properties that's already part of this Terraform provider. As long vApp is enabled, now this can be fully done within the Terraform configuration.

Potential Terraform Provider Configuration

# vapp_transport example configuration

terraform {
  required_providers {
    vsphere = {
      source = "hashicorp/vsphere"
    }
  }
}

provider "vsphere" {
  vsphere_server = "host"
  user           = "user"
  password       = "password"
}

data "vsphere_content_library" "lib" {
  name = "NAME"
}

# An OVF image that has vApp enabled
data "vsphere_content_library_item" "ova" {
  name       = "SOME-IMAGE"
  type       = "OVA"
  library_id = data.vsphere_content_library.lib.id
}

data "vsphere_datacenter" "datacenter" {
  name = "hostname"
}

data "vsphere_datastore" "vsan" {
  name          = "vsanDatastore"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_resource_pool" "iqm_pool" {
  name          = "pool"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

resource "vsphere_virtual_machine" "vm" {
  name             = "VM-NAME"
  resource_pool_id = data.vsphere_resource_pool.iqm_pool.id
  datastore_id     = data.vsphere_datastore.vsan.id
  folder           = "folder"

  num_cpus        = 2
  cpu_reservation = 2000
  memory          = 4096

  disk {
    label            = "VM-NAME"
    size             = 64
  }

  clone {
    template_uuid = data.vsphere_content_library_item.ova.id
  }

  # Possible values are: "iso", "com.vmware.guestInfo", ""
  vapp_transport = ["com.vmware.guestInfo"]

  # vapp {
  #   properties = {
  #     "guestinfo.test" = "test"
  #   }
  # }
}

References

No response

github-actions[bot] commented 1 month ago

Hello, wvanderwaal-iqmessenger! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.