hashicorp / terraform-provider-vsphere

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

OVF deployment failure (v1.24.1) #1239

Closed scluff closed 2 years ago

scluff commented 4 years ago

Terraform Version

0.13.4

vSphere Provider Version

1.24.1

Affected Resource(s)

variable "vsphere_user" { type = string description = "This is the username for vSphere API operations." }

variable "vsphere_password" { type = string description = "This is the password for vSphere API operations." }

variable "vsphere_server" { type = string description = "This is the vCenter server name for vSphere API operations." }

variable "vsphere_insecure" { type = bool description = "Boolean that can be set to true to disable SSL certificate verification. This should be used with care as it could allow an attacker to intercept your auth token." default = false }

variable "vsphere_datacenter" { type = string }

variable "vsphere_cluster" { type = string }

variable "vsphere_host" { type = string }

variable "vsphere_datastore" { type = string }

variable "vsphere_dvs" { type = string }

variable "network_grid" { type = string }

variable "network_admin" { type = string }

variable "network_client" { type = string }

provider "vsphere" { user = var.vsphere_user password = var.vsphere_password vsphere_server = var.vsphere_server allow_unverified_ssl = var.vsphere_insecure }

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

data "vsphere_resource_pool" "pool" { name = "${var.vsphere_cluster}/Resources" datacenter_id = data.vsphere_datacenter.datacenter.id }

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

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

data "vsphere_distributed_virtual_switch" "dvs" { name = var.vsphere_dvs datacenter_id = data.vsphere_datacenter.datacenter.id }

data "vsphere_network" "grid" { name = var.network_grid datacenter_id = data.vsphere_datacenter.datacenter.id distributed_virtual_switch_uuid = data.vsphere_distributed_virtual_switch.dvs.id }

data "vsphere_network" "admin" { name = var.network_admin datacenter_id = data.vsphere_datacenter.datacenter.id distributed_virtual_switch_uuid = data.vsphere_distributed_virtual_switch.dvs.id }

data "vsphere_network" "client" { name = var.network_client datacenter_id = data.vsphere_datacenter.datacenter.id distributed_virtual_switch_uuid = data.vsphere_distributed_virtual_switch.dvs.id }

resource "vsphere_virtual_machine" "primary-admin" { name = "sglab-primary-admin" datacenter_id = data.vsphere_datacenter.datacenter.id resource_pool_id = data.vsphere_resource_pool.pool.id host_system_id = data.vsphere_host.host.id datastore_id = data.vsphere_datastore.datastore.id wait_for_guest_net_timeout = 0 num_cpus = 8 memory_reservation = 0

ovf_deploy { local_ovf_path = "/home/scluff/StorageGRID-Webscale-11.4.0/vsphere/vsphere-primary-admin.ovf" disk_provisioning = "thin" ovf_network_map = { "Grid Network" = data.vsphere_network.grid.id "Admin Network" = data.vsphere_network.admin.id "Client Network" = data.vsphere_network.client.id } } lifecycle { ignore_changes = [ host_system_id ] } vapp { properties = { "GRID_NETWORK_GATEWAY" = "10.0.0.1" "GRID_NETWORK_IP" = "10.0.0.2" "GRID_NETWORK_MASK" = "255.255.255.0" "NODE_NAME" = "primary-admin" } } }

### Debug Output

2020-10-15T17:36:14.063-0700 [DEBUG] plugin.terraform-provider-vsphere_v1.24.1_x4: panic: runtime error: index out of range [0] with length 0 2020-10-15T17:36:14.063-0700 [DEBUG] plugin.terraform-provider-vsphere_v1.24.1_x4: 2020-10-15T17:36:14.063-0700 [DEBUG] plugin.terraform-provider-vsphere_v1.24.1_x4: goroutine 52 [running]: 2020-10-15T17:36:14.063-0700 [DEBUG] plugin.terraform-provider-vsphere_v1.24.1_x4: github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/virtualdevice.DiskPostCloneOperation(0xc000548f50, 0xc00049e010, 0xc000213100, 0x10, 0x10, 0x5, 0xc000663100, 0x5, 0x8, 0x5, ...) 2020-10-15T17:36:14.063-0700 [DEBUG] plugin.terraform-provider-vsphere_v1.24.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/virtualdevice/virtual_machine_disk_subresource.go:1008 +0x23d7


### Panic Output
https://gist.github.com/scluff/84393828e05d7cf5f7cf8c6e815e2f5d
### Expected Behavior
The OVF is deployed and the VM starts
### Actual Behavior
The OVF is deployed but the VM does not start
### Steps to Reproduce
1. `terraform apply`
### Important Factoids
Works correctly with the 1.24.0 provider
### References
* #1221
* #1227
### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
Eslih commented 4 years ago

I am having the same issue. More precisely I try to deploy virtual ESXi hosts. Used the script available at https://www.virtuallyghetto.com/2020/06/full-ova-ovf-property-support-coming-to-terraform-provider-for-vsphere.html

I am using the vsphere v1.24.2 plugin, terraform 0.13.4.

Eslih commented 4 years ago

I am having the same issue. More precisely I try to deploy virtual ESXi hosts. Used the script available at https://www.virtuallyghetto.com/2020/06/full-ova-ovf-property-support-coming-to-terraform-provider-for-vsphere.html

I am using the vsphere v1.24.2 plugin, terraform 0.13.4.

I just downgraded the plugin version to v1.24.0. This seems to work like expected!

adarobin commented 3 years ago

1218 seems to have caused this issue. It looks like all of the arguments that had the DiffSuppressFunc removed from them get deleted after the OVF has been cloned because they aren't declared in the TF code. I noticed this trying to deploy a nested ESXi appliance and discovering all of my network cards were gone after a reconfiguration that got kicked off after the deployment.

I confirmed this locally. I pulled master and then ran git revert 649c894744ded10e22b14ac89bb2f881ac836c84. With that done and compiled I am able to deploy the nested ESXi appliance as in v1.24.0.

adarobin commented 3 years ago

@bill-rich Is #1218 working as intended? Should I need to have all of these different hardware elements declared in my resource when I am deploying an OVF?

tenthirtyam commented 2 years ago

@scluff -

Have you tested deploying the OVA with the latest (e.g. v2.0.2) version of the provider?

See https://github.com/hashicorp/terraform-provider-vsphere/issues/1227#issuecomment-1005112446 for an example using the Nested_ESXi7.0u3_Appliance_Template_v1.ova OVA image along with the vsphere_ovf_vm_template data source.

Ryan

tenthirtyam commented 2 years ago

@scluff -

Have you tested deploying the OVA with the latest (e.g. v2.0.2) version of the provider?

See https://github.com/hashicorp/terraform-provider-vsphere/issues/1227#issuecomment-1005112446 for an example using the Nested_ESXi7.0u3_Appliance_Template_v1.ova OVA image along with the vsphere_ovf_vm_template data source.

Ryan Johnson Staff II Solutions Architect, VMware, Inc.

tenthirtyam commented 2 years ago

Marking this issue as resolved based on the solution example provided in the previous comments (1) (2) with the example for deploying the Nested_ESXi7.0u3_Appliance_Template_v1.ova OVA image.

If the issue persists with the solution provided, the latest version of the provider, and the recommended use of the vsphere_ovf_vm_template data source, please open a new issue and reference this issue for additional context.

Ryan Johnson Staff II Solutions Architect, VMware, Inc.

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.