terraform vsphere provider hangs while creating vm
Asked Answered
R

0

6

I'm trying to create a VM based on a template (ubuntu 18.04) using terraform and vsphere provider. The final error showed by terraform apply.. command is:

* vsphere_virtual_machine.vm: timeout waiting for an available IP address

However, the VM is created and receives the IP address set in "clone" section inside vsphere_virtual_machine resource.

resource "vsphere_virtual_machine" "vm" {
  count = "${var.count}"
  name = "${lookup(var.vm_name, count.index + 1)}"

  resource_pool_id = "${data.vsphere_resource_pool.pool.id}"
  datastore_id = "${data.vsphere_datastore.datastore.id}"

  network_interface {
    network_id = "${data.vsphere_network.network.id}"
    adapter_type = "${data.vsphere_virtual_machine.template.network_interface_types[0]}"
  }

  disk {
      ...
  }

  clone {
    template_uuid = "${data.vsphere_virtual_machine.template.id}"
    customize {
      linux_options {
        host_name = "${lookup(var.hostname, count.index + 1)}"
        domain = "${var.domain}"
      }

      dns_server_list = ["${var.ns1}", "${var.ns2}"]
      network_interface {
        ipv4_address = "${lookup(var.ipv4_address, count.index + 1)}"
        ipv4_netmask = "${var.ipv4_netmask}"
      }
      ipv4_gateway = "${var.ipv4_gateway}"
    }

  }
}

The toolsDeployPkg.log file shows the following error:

[2018-09-10T18:07:12.557Z] [    info] ENTER STATE Done 
[2018-09-10T18:07:12.557Z] [    info] EXIT STATE INPROGRESS 
[2018-09-10T18:07:12.557Z] [    info] Deployment succeeded. 
[2018-09-10T18:07:12.557Z] [    info] Launching cleanup. 
[2018-09-10T18:07:12.557Z] [   debug] Command to exec : /bin/rm 
[2018-09-10T18:07:12.557Z] [    info] sizeof ProcessInternal is 56
[2018-09-10T18:07:12.557Z] [    info] Returning, pending output from stdout
[2018-09-10T18:07:12.558Z] [    info] Returning, pending output from stderr
[2018-09-10T18:07:12.658Z] [    info] Process exited normally after 0 seconds, returned 0
[2018-09-10T18:07:12.658Z] [    info] No more output from stdout
[2018-09-10T18:07:12.658Z] [    info] No more output from stderr
[2018-09-10T18:07:12.658Z] [    info] Customization command output: 
[2018-09-10T18:07:12.658Z] [    info] sSkipReboot: false, forceSkipReboot false
[2018-09-10T18:07:12.658Z] [   debug] Ran DeployPkg_DeployPackageFromFile successfully
[2018-09-10T18:07:12.658Z] [   debug] ## Closing log
[2018-09-10T18:07:12.658Z] [    info] Rebooting
[2018-09-10T18:07:12.658Z] [   debug] Command to exec : /sbin/telinit 
[2018-09-10T18:07:12.658Z] [    info] sizeof ProcessInternal is 56

[2018-09-10T18:07:12.658Z] [    info] Returning, pending output from stdout
[2018-09-10T18:07:12.658Z] [    info] Returning, pending output from stderr
[2018-09-10T18:07:12.769Z] [   error] Process exited abnormally after 0 sec, uncaught signal 15
[2018-09-10T18:07:12.769Z] [    info] No more output from stdout
[2018-09-10T18:07:12.769Z] [    info] No more output from stderr
[2018-09-10T18:07:12.769Z] [    info] Customization command output: 
[2018-09-10T18:07:13.633Z] [   error] telinit returned error 127

Do I need to configure other options into vCenter? I'm using the following softwares:

  • Terraform v0.11.8
  • provider.vsphere v1.7.0
  • vCenter 6.7
Roadhouse answered 10/9, 2018 at 18:39 Comment(3)
I suspect the Ubuntu OVA has to be configured using vApp options and ISO transport. Read this thread for some more information: github.com/terraform-providers/terraform-provider-vsphere/…Santiagosantillan
Actually, I created a template from a fresh install Ubuntu 18.04.1. I will try to use ubuntu ova. ThanksRoadhouse
Does the template you are using have an available IP address? I found I had to effectively reserve an IP for my template to customize. I cannot tell if your VM is actually failing to build, or if it is failing during the customization operation. Caveat: I use static IPs.Misdoubt

© 2022 - 2024 — McMap. All rights reserved.