2

I am by no means a knowledgeable VMWare user at this point. I think this might just be a case where I just don't understand some essential concepts.

I'm trying to deploy a VM into a VCenter, I have an OVA (template?) that I want to deploy with.

Currently I have unpacked the OVA, uploaded the VMDKs I found therein to a datastore, and then used this terraform definition:

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

resource "vsphere_virtual_machine" "primary" {
  name =  "myvm"
  vcpu = 2
  memory = 16384
  datacenter = "${var.vsphere_datacenter}"
  resource_pool = "/DATA_CENTER/host/10.132.260.000"

  network_interface = {
    label = "Private Network - vmnic0 vmnic2"
    ipv4_address = "10.132.260.001"
    ipv4_gateway = "10.132.260.002"
    ipv4_prefix_length = 26
  }

  disk {
    datastore = "datastore1"
    vmdk = "/path/to/vmdk/"
    bootable = true
    type = "thin"
  }
}

Which gets stuck, because it can't open the VMDK.

When I deploy the OVA with ovftool the vmdk that the vm is deployed with is very different.

An error was received from the ESX host while powering on VM myvm. Failed to start the virtual machine. Module DiskEarly power on failed. Cannot open the disk '/vmfs/volumes/557fc17b-c078f45c-f5bf-002590faf644/template_folder/my_vm.vmdk' or one of the snapshot disks it depends on. The file specified is not a virtual disk

Should I be uploading the OVA file to the datastore instead and change my disk block to look like:

disk {
  datastore = "datastore1"
  template = "/path/to/ova/"
  type = "thin"
}

Or am I just out of luck here? Also, the terraform provider for vsphere doesn't correctly receive the error from VCenter and just continues to poll even though the vm failed.

Breedly
  • 12,838
  • 13
  • 59
  • 83
  • If anyone knows where the code for this resource is; I would also like to know and possibly contribute back. – Breedly Feb 07 '17 at 15:09
  • did you manage to resolve this? – Rekovni Oct 10 '17 at 10:54
  • @Rekovni I haven't had a chance to try. I had been trying to follow development issues concerning this. I really don't know how I would even go about building this though. – Breedly Oct 10 '17 at 14:42
  • Hmm, there is a ticket at the moment for OVA upload support (https://github.com/terraform-providers/terraform-provider-vsphere/issues/74), but doesn't mention anything about using a template to OVA. – Rekovni Oct 10 '17 at 14:58
  • I'm just trying to do something similar but with a vmdk file, but having issues with that, but OVA would be a lot easier! – Rekovni Oct 10 '17 at 14:59
  • Try first to import OVA file into vCenter, this way you will create a new virtual machine. Then resize machine disk size to whatever suits your needs. Finallly convert it into a Virtual Machine template. This is the template you must use on `template` property on terraform-vsphere-provider. – amarruedo Dec 20 '17 at 14:32

1 Answers1

0

OVA contains streamOptimized disks. If you directly upload to the datastore vSphere doesn't recognize it as a VMDK for a VM.

You can use vmware-vdiskmanager tool to convert the streamOptimized disk to sparse disk.

vmware-vdiskmanager -r ova_extracted.vmdk -t 0 destination.vmdk

chinmay
  • 672
  • 6
  • 15