hashicorp / terraform-provider-vsphere

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

vApp option value for dynamic disk ignored with ovf_deploy block #1987

Open remrozk opened 1 year ago

remrozk commented 1 year ago

Community Guidelines

Terraform

v1.5.5

Terraform Provider

v2.4.0

VMware vSphere

v7.0.3

Description

I tried to pass a disk size in the vApp option named vmdisk_capacity when I use ovf_deploy and vapp blocks. The value will be used during the deployment of the OVF template to create an additional disk with a "dynamic" value.

The code works with the clone block. The OVF template also works fine with the vSphere web interface and with the govc binary.

If I use the ovf_deploy block, the value in the vApp option is correctly set, but the default value of this vApp option is used during the deployment.

Affected Resources or Data Sources

resource\vsphere_virtual_machine

Terraform Configuration

main.tf

resource "vsphere_virtual_machine" "vm" {
  name                       = "vm"
  resource_pool_id           = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_id               = data.vsphere_datastore.datastore.id
  num_cpus                   = "2"
  num_cores_per_socket       = "2"
  memory                     = "4096"
  folder                     = ""
  guest_id                   = ""
  hardware_version           = 19
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout  = 0
  scsi_controller_count      = 1
  host_system_id             = data.vsphere_host.ovf_host.id
  datacenter_id              = data.vsphere_datacenter.datacenter.id
  disk {
    unit_number  = 0
    label        = "root"
    size         = "128"
    datastore_id = data.vsphere_datastore.datastore.id
  }
  ovf_deploy {
    remote_ovf_url           = var.vm_ovf_url_template
    enable_hidden_properties = true
  }
  vapp {
    properties = {
      "guestinfo.hostname"         = "vm",
      "guestinfo.password"         = "#AnAmazingPassw0rd#"
      "guestinfo.password_crypted" = "False"
      "guestinfo.user"             = "user1"
      "vmdisk2_capacity"           = "100"
    }
  }
}

data.tf

data "vsphere_datacenter" "datacenter" {
  name = var.vsphere_datacenter
}

data "vsphere_datastore" "datastore" {
  name          = var.vm_datastore
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_compute_cluster" "cluster" {
  name          = var.vsphere_compute_cluster
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_host" "ovf_host" {
  name          = var.vm_ovf_host
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

variables.tf

variable "vsphere_datacenter" {
  type        = string
  description = "Name of the datacenter in vSphere interface"
}

variable "vm_datastore" {
  type        = string
  description = "Name of the datastore to store virtual machines"
}

variable "vsphere_compute_cluster" {
  type        = string
  description = "Name of the vSphere cluster"
}

variable "vm_ovf_host" {
  type        = string
  description = "Name of the host to deploy the OVF template"
}

variable "vm_ovf_url_template" {
  type        = string
  description = "URL of the OVF template"
}

Debug Output

https://gist.github.com/remrozk/069bb4b6fc2f0660d017d09088e88feb

Panic Output

No response

Expected Behavior

The additional disks created during the OVF deployment should be with the size set in the vApp option, not the default value of this vApp option.

Actual Behavior

The additional disks are created during the OVF deployment with the default value of the vApp option, the size set in the vApp option is ignored during the deployment, even if the vApp option is correctly set in the virtual machine.

Steps to Reproduce

  1. In the OVF file, add this section:

    <DiskSection>
    <Info>Virtual disk information</Info>
    <Disk ovf:capacity="128" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
    <Disk ovf:capacity="${vmdisk2_capacity}" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk2" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
    </DiskSection>
  2. In the ProductSection, add this section:

    <Property ovf:key="vmdisk2_capacity" ovf:runtimeConfigurable="false" ovf:type="int" ovf:qualifiers="MinValue(32) MaxValue(6000)" ovf:value="32" ovf:userConfigurable="true">
    <Label>Disk</Label>
    <Description>Volume size in gigabytes.</Description>
    </Property>
  3. Run Terraform which calls the OVF template with the URL.

Environment Details

No response

Screenshots

vApp options

vapp_options

Settings

settings

References

No response

github-actions[bot] commented 1 year ago

Hello, remrozk! πŸ–

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.

remrozk commented 10 months ago

Hi team,

Do you have some news?

Thank you for your assistance, -- remrozk