hashicorp / terraform-provider-vsphere

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

Error: timeout waiting for an available IP address #1786

Closed Aokigahara23 closed 9 months ago

Aokigahara23 commented 2 years ago

Community Guidelines

Terraform

v1.2.7

Terraform Provider

v2.2.0

VMware vSphere

v6.5.0.38000

Description

Terraform OVF deployment to one of vCenters failes with Error: timeout waiting for an available IP address. Deploying the same OVF manually works fine

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

Module entrypoint

# OVF TEMPLATE DEPLOY

module "ovf_deploy" {
  source = "./modules/ovf_template"

  ovf_template_metadata = var.ovf_template_metadata
  vsphere_vm_name       = var.vsphere_vm_name

  vsphere_vm_annotation = var.vsphere_vm_annotation
  vsphere_datacenter    = var.vsphere_datacenter
  vsphere_host          = var.vsphere_host
  vsphere_datastore     = var.vsphere_datastore
  vsphere_resource_pool = var.vsphere_resource_pool
  vsphere_folder        = var.vsphere_folder
  vsphere_networks      = var.vsphere_networks

  vsphere_vm_cpu_count   = var.vsphere_vm_cpu_count
  vsphere_vm_ram         = var.vsphere_vm_ram
  vsphere_vm_extra_disks = var.vsphere_vm_extra_disks
  vsphere_tags           = var.vsphere_tags
}

Module itself

# OVF template data

data "vsphere_ovf_vm_template" "ovf" {
  name             = var.ovf_template_metadata.temporary_template_name
  resource_pool_id = var.vsphere_resource_pool.vid
  datastore_id     = var.vsphere_datastore.vid
  host_system_id   = var.vsphere_host.vid
  remote_ovf_url   = var.ovf_template_metadata.template_url
}

# Deploy

resource "vsphere_virtual_machine" "target_vm" {
  name                 = var.vsphere_vm_name
  annotation           = var.vsphere_vm_annotation
  datacenter_id        = var.vsphere_datacenter.vid
  resource_pool_id     = var.vsphere_resource_pool.vid
  host_system_id       = var.vsphere_host.vid
  datastore_id         = var.vsphere_datastore.vid
  folder               = var.vsphere_folder.abspath
  num_cpus             = var.vsphere_vm_cpu_count > 1 ? var.vsphere_vm_cpu_count : 1
  num_cores_per_socket = var.vsphere_vm_cpu_count > 1 ? var.vsphere_vm_cpu_count / 2 : 1
  memory               = var.vsphere_vm_ram
  guest_id             = data.vsphere_ovf_vm_template.ovf.guest_id
  scsi_type            = "pvscsi"
  tags                 = var.vsphere_tags

  wait_for_guest_net_timeout = 20
  wait_for_guest_ip_timeout  = 20

  extra_config = {
    "isolation.tools.copy.disable"         = false
    "isolation.tools.paste.disable"        = false
    "isolation.tools.setGUIOptions.enable" = true
    "svga.autodetect"                      = true
  }

  # Network intefaces

  dynamic "network_interface" {
    for_each = var.vsphere_networks

    content {
      network_id   = network_interface.value.network.vid
      adapter_type = network_interface.value.adapter_type
    }
  }

  # Deploy disks from the provided OVF meta data

  dynamic "disk" {
    for_each = var.ovf_template_metadata.template_disk_map

    content {
      label            = disk.value.label
      size             = disk.value.size
      thin_provisioned = true
      unit_number      = disk.key
    }
  }

  # Deploy extra disks if they were passed

  dynamic "disk" {
    for_each = var.vsphere_vm_extra_disks

    content {
      datastore_id     = disk.value.datastore.vid
      label            = disk.value.label
      size             = disk.value.size
      thin_provisioned = true
      unit_number      = length(var.ovf_template_metadata.template_disk_map) + disk.key
    }
  }

  ovf_deploy {
    allow_unverified_ssl_cert = true
    disk_provisioning         = "thin"
    remote_ovf_url            = data.vsphere_ovf_vm_template.ovf.remote_ovf_url
    ip_protocol               = "IPV4"
    ip_allocation_policy      = "DHCP"
  }
}

Debug Output

+ terraform apply -auto-approve -compact-warnings
module.ovf_deploy[0].data.vsphere_ovf_vm_template.ovf: Reading...
module.ovf_deploy[0].data.vsphere_ovf_vm_template.ovf: Read complete after 0s [id=windows-server-2019-gui]

Terraform used the selected providers to generate the following execution

plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.ovf_deploy[0].vsphere_virtual_machine.target_vm will be created
  + resource "vsphere_virtual_machine" "target_vm" {
      + annotation                              = "********************"
      + boot_retry_delay                        = 10000
      + change_version                          = (known after apply)
      + cpu_limit                               = -1
      + cpu_share_count                         = (known after apply)
      + cpu_share_level                         = "normal"
      + datacenter_id                           = "datacenter-10489"
      + datastore_id                            = "datastore-10498"
      + default_ip_address                      = (known after apply)
      + ept_rvi_mode                            = "automatic"
      + extra_config                            = {
          + "isolation.tools.copy.disable"         = "false"
          + "isolation.tools.paste.disable"        = "false"
          + "isolation.tools.setGUIOptions.enable" = "true"
          + "svga.autodetect"                      = "true"
        }
      + firmware                                = "bios"
      + folder                                  = "*************"
      + force_power_off                         = true
      + guest_id                                = "windows9Server64Guest"
      + guest_ip_addresses                      = (known after apply)
      + hardware_version                        = (known after apply)
      + host_system_id                          = "host-10496"
      + hv_mode                                 = "hvAuto"
      + id                                      = (known after apply)
      + ide_controller_count                    = 2
      + imported                                = (known after apply)
      + latency_sensitivity                     = "normal"
      + memory                                  = 2048
      + memory_limit                            = -1
      + memory_share_count                      = (known after apply)
      + memory_share_level                      = "normal"
      + migrate_wait_timeout                    = 30
      + moid                                    = (known after apply)
      + name                                    = "*************"
      + num_cores_per_socket                    = 1
      + num_cpus                                = 2
      + power_state                             = (known after apply)
      + poweron_timeout                         = 300
      + reboot_required                         = (known after apply)
      + resource_pool_id                        = "resgroup-551826"
      + run_tools_scripts_after_power_on        = true
      + run_tools_scripts_after_resume          = true
      + run_tools_scripts_before_guest_shutdown = true
      + run_tools_scripts_before_guest_standby  = true
      + sata_controller_count                   = 0
      + scsi_bus_sharing                        = "noSharing"
      + scsi_controller_count                   = 1
      + scsi_type                               = "pvscsi"
      + shutdown_wait_timeout                   = 3
      + storage_policy_id                       = (known after apply)
      + swap_placement_policy                   = "inherit"
      + tools_upgrade_policy                    = "manual"
      + uuid                                    = (known after apply)
      + vapp_transport                          = (known after apply)
      + vmware_tools_status                     = (known after apply)
      + vmx_path                                = (known after apply)
      + wait_for_guest_ip_timeout               = 20
      + wait_for_guest_net_routable             = true
      + wait_for_guest_net_timeout              = 20
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = (known after apply)
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 0
          + io_share_count    = 0
          + io_share_level    = "normal"
          + keep_on_remove    = false
          + key               = (known after apply)
          + label             = "disk-0"
          + path              = (known after apply)
          + size              = 100
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 0
          + uuid              = (known after apply)
          + write_through     = false
        }

      + network_interface {
          + adapter_type          = "vmxnet3"
          + bandwidth_limit       = -1
          + bandwidth_reservation = 0
          + bandwidth_share_count = (known after apply)
          + bandwidth_share_level = "normal"
          + device_address        = (known after apply)
          + key                   = (known after apply)
          + mac_address           = (known after apply)
          + network_id            = "network-10497"
        }

      + ovf_deploy {
          + allow_unverified_ssl_cert = true
          + disk_provisioning         = "thin"
          + enable_hidden_properties  = false
          + ip_allocation_policy      = "DHCP"
          + ip_protocol               = "IPV4"
          + remote_ovf_url            = "http://qaldaminio.qacfg.veeam.local:9000/templates/windows-server-2019-gui/windows-server-2019-gui-template.ovf"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + vm_data = {
      + guest_id   = "windows9Server64Guest"
      + ip_address = (known after apply)
    }

module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Creating...
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [1m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [2m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [3m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [4m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [5m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [6m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [7m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [8m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [9m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [10m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [11m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [12m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [13m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [14m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [15m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [16m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [17m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [18m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m0s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m10s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m20s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m30s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m40s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [19m50s elapsed]
module.ovf_deploy[0].vsphere_virtual_machine.target_vm: Still creating... [20m0s elapsed]

Error: timeout waiting for an available IP address

   with module.ovf_deploy[0].vsphere_virtual_machine.target_vm,
   on modules/ovf_template/main.tf line 13, in resource "vsphere_virtual_machine" "target_vm":
   13: resource "vsphere_virtual_machine" "target_vm" {

Panic Output

No response

Expected Behavior

Terraform deploys OVF template by reading remote .ovf file meta and uploads everything it needs on the target vCenter. (.ovf, ,vmdk, .mf) files.

Actual Behavior

For some unknown reason since the end of last week .vmdk file is downloaded empty image

here is a view of datastore folder from screenshot above image

here is a folder on the http-storage (where .ovf is stored) image

As you can see .vmdk is 0KB

On other vCenter servers there is no such problem

Manual ovf deployment on this vCenter via web-ui works without problem

Steps to Reproduce

Run ovf deployment with environment specified above

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 2 years ago

Hello, Aokigahara23! 🖐

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.

tenthirtyam commented 2 years ago

Is this issue seen on vSphere 7.0 or later?

matthew-palmer commented 1 year ago

Although not from a OVF deployment, I have seen this behavior on a vsphere_virtual_machine when cloning from template. It seems to be exclusively an issue with windows where the network adapter is assigned but not attached. Manually connecting the adapter during terraform apply while the clone is happening will cause a terraform apply success

github-actions[bot] commented 8 months 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.