user29408683
user29408683

Reputation: 1

Terraform Config File, IP timeout

For some reason the terraform config below is timing out waiting for an ip address and I am not sure why I have a static ip in the file? Is it an issue with the template I am cloning from if so how do I fix it?

I've tried changing it to what I have seen here but it just wont work I am lost. this is the code:

provider "vsphere" {
  user           = "Username"
  password       = "Password"
  vsphere_server = "vspherserver-placeholder"

  # If you have a self-signed cert
  allow_unverified_ssl = true
}


data "vsphere_datacenter" "dc" {
  name = "datacenter-placeholder"
}

data "vsphere_datastore" "datastore" {
  name          = "vm-storage"
  datacenter_id = data.vsphere_datacenter.dc.id
}

# Parent Resource Pool
data "vsphere_resource_pool" "parent-pool" {
  name          = "resourcepool-place" # Update the destination resource pool
  datacenter_id = data.vsphere_datacenter.dc.id
}

# Child Resource Pool
data "vsphere_resource_pool" "child-pool" {
  name          = "resource-pool" # Update the destination resource pool
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_host" "host" {
  name          = "host-place"
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_network" "network" {
  name          = "VM Network"
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_virtual_machine" "source_vm" {
  name          = "UBUNTU-WKST-16.04" # VM that should be cloned
  datacenter_id = data.vsphere_datacenter.dc.id
}

resource "vsphere_virtual_machine" "vm" {
  name             = "Ubuntu1" # Name of the VM that is created
  resource_pool_id = data.vsphere_resource_pool.child-pool.id
  datastore_id     = data.vsphere_datastore.datastore.id

  num_cpus = data.vsphere_virtual_machine.source_vm.num_cpus # Taken From Cloned VM
  memory   = data.vsphere_virtual_machine.source_vm.memory
  guest_id = "ubuntu64Guest"  # Ensure this matches your Linux distribution

  network_interface {
    network_id   = data.vsphere_network.network.id
    adapter_type = "vmxnet3"
  }

  disk {
  label            = "VMoutput_disk0"
  size             = data.vsphere_virtual_machine.source_vm.disks.0.size
  eagerly_scrub    = false
  thin_provisioned = true
}
  

  clone {
    template_uuid = data.vsphere_virtual_machine.source_vm.id

    customize {
      linux_options {
        host_name = "linux"  # Simplified hostname
        domain    = "local"
      }

      network_interface { 
        ipv4_address = "x.x.x.x" # change to dhcp later
        ipv4_netmask = 24
      }

      ipv4_gateway = "x.x.x.x"
      dns_server_list = ["1.0.0.1", "1.1.1.1"]
    }
  }
} 

Upvotes: -2

Views: 22

Answers (0)

Related Questions