vsphere clone showing up with no network

448 views
Skip to first unread message

Aaron Kulbe

unread,
Oct 11, 2020, 6:00:03 PM10/11/20
to Terraform
I am running vSphere 7.0u1, and Terraform 0.13.4, and version 1.24.1 of the vsphere provider for TF.

My issue is that when I attempt to clone a VM, it comes up with no network. I have tried with CentOS 7.x, 8.x and Ubuntu. The results are the same.

I can clone each template right in vCenter, and everything works fine.


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

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

data "vsphere_datastore" "datastore" {
  name          = var.vsphere_datastore
}

data "vsphere_compute_cluster" "cluster" {
  name          = var.vsphere_cluster
}

data "vsphere_resource_pool" "pool" {
  name          = "LVBcluster/Resources"
}

data "vsphere_network" "network" {
  name          = var.vsphere_network
}

data "vsphere_virtual_machine" "template" {
  name          = var.vsphere_virtual_machine_template
}

resource "vsphere_virtual_machine" "cloned_virtual_machine" {
  name             = var.vsphere_virtual_machine_name
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  #resource_pool_id = data.vsphere_resource_pool.pool.id


  num_cpus = 1
  memory   = 2048
  guest_id = data.vsphere_virtual_machine.template.guest_id

  scsi_type = data.vsphere_virtual_machine.template.scsi_type

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

  disk {
    label            = "disk0"
    size             = data.vsphere_virtual_machine.template.disks.0.size
    eagerly_scrub    = data.vsphere_virtual_machine.template.disks.0.eagerly_scrub
    thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
  }

  clone {

    customize {
      linux_options {
        host_name = "localhost"
        domain    = "localdomain"
      }
      network_interface {}
    }
  }
}


# vsphere login account. defaults to admin account
variable "vsphere_user" {
  default = "admini...@vsphere.local"
}

# vsphere account password. empty by default.
variable "vsphere_password" {
  default = "<snip>"
}

# vsphere server, defaults to localhost
variable "vsphere_server" {
  default = "<snip>"
}

# vm name
variable "vsphere_virtual_machine_name" {
  default = "clone"
}

# vsphere datacenter the virtual machine will be deployed to. empty by default.
variable "vsphere_datacenter" {
  default = "LVB"
}

# vsphere resource pool the virtual machine will be deployed to. empty by default.
variable "vsphere_resource_pool" {
  default = ""
}

# vsphere datastore the virtual machine will be deployed to. empty by default.
variable "vsphere_datastore" {
  default = "datastore1"
}

# vsphere cluster the virtual machine will be deployed to.
variable "vsphere_cluster" {
  default = "LVBcluster"
}

# vsphere network the virtual machine will be connected to. empty by default.
variable "vsphere_network" {
  default = "VM Network"
}

# vsphere virtual machine template that the virtual machine will be cloned from. empty by default.
variable "vsphere_virtual_machine_template" {
  default = "Template_C8"
}

# the name of the vsphere virtual machine that is created. empty by default.
#variable "vsphere_virtual_machine_name" {}

Aaron Kulbe

unread,
Oct 12, 2020, 4:56:09 PM10/12/20
to Terraform
I wanted to elaborate further on this. I watched the clone action in vSphere while TF was running, and the VM comes up fine, and the network interface is there, but it's disconnected.

James Osbourn

unread,
Oct 13, 2020, 6:57:55 AM10/13/20
to terrafo...@googlegroups.com
Have you verified that the networking is set to connected in the template?  Even manually the networking is disconnected.

James

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/c8d5ea19-b70b-495e-a0be-d29415c33b26n%40googlegroups.com.

Aaron Kulbe

unread,
Oct 13, 2020, 4:18:42 PM10/13/20
to Terraform
I'm not sure what you mean, in either case.

First, when I look at the documentation for "vsphere_network", I don't see any options for specifying it can/should be connected or not. Am I missing something?

Second, when I manually clone the template in vSphere, it isn't disconnected at all. It connects to the network, out of the box.

Can you elaborate, please?

Reply all
Reply to author
Forward
0 new messages