• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

virtuallyGhetto

  • About
  • Privacy
  • VMware Cloud
  • Home Lab
  • Nested Virtualization
  • Automation
    • VMware Kickstart
    • VMware API/SDK/CLI
    • VMware vMA/VIMA
    • VMware OVF / OVFTOOL
  • Apple Mac
  • VCSA
  • VSAN
You are here: Home / Automation / Full OVA/OVF property support coming to Terraform provider for vSphere

Full OVA/OVF property support coming to Terraform provider for vSphere

06/11/2020 by William Lam 13 Comments

Terraform is one of the most popular Infrastructure as Code (IaC) tool out there today and it should come as no surprise there is Terraform provider for vSphere which many of our customers have been using. In fact, VMware just recently released a couple more new providers (here and here) supporting VMware Cloud on AWS and NSX-T solutions respectively.

Although I have used Terraform and the vSphere provider in the past, it has not been my tool of choice for automation as it still lacks a number of basic vSphere capabilities which I require on a regular basis. The most common one being the ability to deploy a Virtual Appliance (OVA/OVF) which has been my biggest barrier and I know this has been a highly requested feature from the community as well.

In early May of this year, I noticed that v1.18 of the vSphere provider finally added support for OVA/OVF deployment and I was pretty excited to give this a try and may even have been the first to kick the tires on this feature? Although OVA/OVF support was added, it looks like support for customizing OVF properties which is commonly included as part of an OVA/OVF would only possible if you are cloning from an existing imported OVA/OVF image. One of the most common use case is to import an OVF/OVA from either your local computer or from a URL and it looks like this use case was not possible.

I filed two Github issues, one for supporting OVF properties for initial OVA/OVF deployment and another regarding a bug I ran into when importing OVA/OVF from a remote URL. Just yesterday, I got the good news that my feature request has been completed and I was given an early drop of the vSphere provider to try out this feature. I may have also hinted to the Engineering team to use my popular Nested ESXi Appliance OVA as a reference test implementation as I knew this was something many customers will want to deploy 🙂

UPDATE (06/23/20) - Support for OVA/OVF properties is now available as part of 1.20 of the Terraform Provider for vSphere

Here is a working example of deploying my Nested ESXi OVA both from my local computer as well as from a remote URL:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
provider "vsphere" {
  user           = "*protected email*"
  password       = "VMware1!"
  vsphere_server = "192.168.30.200"
 
  # If you have a self-signed cert
  allow_unverified_ssl = true
}
 
data "vsphere_datacenter" "datacenter" {
  name = "Primp-Datacenter"
}
 
data "vsphere_datastore" "datastore" {
  name          = "sm-vsanDatastore"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}
 
data "vsphere_resource_pool" "pool" {
  name          = "Supermicro-Cluster/Resources/Workload"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}
 
data "vsphere_network" "network" {
  name          = "VM Network"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}
 
data "vsphere_host" "host" {
  name          = "192.168.30.14"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}
 
resource "vsphere_virtual_machine" "vmFromRemoteOvf" {
  name = "Nested-ESXi-7.0-Terraform-Deploy-1"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id = data.vsphere_datastore.datastore.id
  datacenter_id = data.vsphere_datacenter.datacenter.id
  host_system_id = data.vsphere_host.host.id
 
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout = 0
 
  ovf_deploy {
    remote_ovf_url = "https://download3.vmware.com/software/vmw-tools/nested-esxi/Nested_ESXi7.0_Appliance_Template_v1.ova"
    disk_provisioning = "thin"
    ovf_network_map = {
        "VM Network" = data.vsphere_network.network.id
    }
  }
 
  vapp {
    properties = {
      "guestinfo.hostname" = "tf-nested-esxi-1.primp-industries.com",
      "guestinfo.ipaddress" = "192.168.30.180",
      "guestinfo.netmask" = "255.255.255.0",
      "guestinfo.gateway" = "192.168.30.1",
      "guestinfo.dns" = "192.168.30.1",
      "guestinfo.domain" = "primp-industries.com",
      "guestinfo.ntp" = "pool.ntp.org",
      "guestinfo.password" = "VMware1!23",
      "guestinfo.ssh" = "True"
    }
  }
}
 
resource "vsphere_virtual_machine" "vmFromLocalOvf" {
  name = "Nested-ESXi-7.0-Terraform-Deploy-2"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id = data.vsphere_datastore.datastore.id
  datacenter_id = data.vsphere_datacenter.datacenter.id
  host_system_id = data.vsphere_host.host.id
 
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout = 0
 
  ovf_deploy {
    local_ovf_path = "/Volumes/Storage/Software/Nested_ESXi7.0_Appliance_Template_v1.ova"
    disk_provisioning = "thin"
    ovf_network_map = {
        "VM Network" = data.vsphere_network.network.id
    }
  }
 
  vapp {
    properties = {
      "guestinfo.hostname" = "tf-nested-esxi-2.primp-industries.com",
      "guestinfo.ipaddress" = "192.168.30.181",
      "guestinfo.netmask" = "255.255.255.0",
      "guestinfo.gateway" = "192.168.30.1",
      "guestinfo.dns" = "192.168.30.1",
      "guestinfo.domain" = "primp-industries.com",
      "guestinfo.ntp" = "pool.ntp.org",
      "guestinfo.password" = "VMware1!23",
      "guestinfo.ssh" = "True"
    }
  }
}

With this upcoming capability, I think this really opens up the door for more possibilities and may even convince me to start using Terraform on a more regular basis 😉

I am sure many of you are asking when will this be available and happy to say very soon! It looks like the vSphere provider is roughly on a bi-weekly release cadence, so folks should expect to see this available in the next couple of weeks and I will update this blog post once it is available. I will be curious to learn what folks will be deploying and as always, if you have any feedback feel free to leave it here or better yet, file an issue directly in the Github repo.

More from my site

  • How to build a customizable Raspberry Pi OS Virtual Appliance (OVA)?
  • Packer reference for PhotonOS Arm NFS Virtual Appliance using OVF properties for ESXi-Arm
  • Packer reference for building PhotonOS Virtual Appliance using OVF properties 
  • Building your own Virtual Appliances using OVF properties Part 3
  • Building your own Virtual Appliances using OVF properties Part 2
Share this...
  • Twitter
  • Facebook
  • Linkedin
  • Reddit
  • Pinterest

Filed Under: Automation, vSphere Tagged With: ova, ovf, Terraform

Reader Interactions

Comments

  1. Luke @ThepHuck says

    06/11/2020 at 3:47 pm

    I played with this about a month ago. The biggest blocker I still have is it only deploys to vCenter. I wanted to use Terraform to deploy directly to ESXi and ended up using govc instead, which then I just went back to pcli 😂

    Reply
  2. Brad Calvert says

    06/13/2020 at 7:54 am

    Does this have everything needed to deploy a VCSA now?

    Reply
  3. Karthikeyan Raman says

    07/02/2020 at 4:02 am

    Please help here:

    I’m facing the error when using ovf deploy remote url, retired multiple times but same error

    Im recieving the Error: error while importing ovf/ova template, error while uploading the disk ubuntu-bionic-18.04-cloudimg.vmdk error while uploading the file ubuntu-bionic-18.04-cloudimg.vmdk Post “https://esxihostname/nfc/52664264-2800-4db7-abc4-91b312f3efe9/disk-0.vmdk”: dial tcp: lookup esxihostname on 127.0.0.11:53: no such host

    Reply
    • William Lam says

      07/02/2020 at 6:51 am

      Please file any issues you have on the Github Terraform Provider for vSphere https://github.com/hashicorp/terraform-provider-vsphere/issues to get further assistance

      Reply
      • Karthikeyan Raman says

        07/04/2020 at 2:53 am

        Its a simple issue.. sorted out… Thanks for the help
        https://github.com/hashicorp/terraform-provider-vsphere/issues/1096#issuecomment-653136056

        Reply
  4. dmalhot1 says

    09/07/2020 at 3:55 am

    In your example:
    properties = {
    “guestinfo.hostname” = “tf-nested-esxi-2.primp-industries.com”,

    What is the syntax here . What is “guestinfo” and what is “hostname” ?

    How do I extract the name of the properties for my ova ? I used ovatool to fetch details about it but couldn’t make out ?

    Reply
    • William Lam says

      09/07/2020 at 5:53 am

      The syntax is based on what is defined in the OVF properties, which you need to inspect using ovftool or by simply looking at the XML. If its not clear, I suggest you take a look at my example and the Nested ESXi Virtual Appliance to get an idea. As a side note, the property key is the same ones you’d use to pass into ovftool if you’ve used that to deploy any OVF/OVAs that contain OVF properties, so there is nothing new here with respect to Terraform

      Reply
  5. Miguel Ruiz says

    10/16/2020 at 4:44 pm

    Hi William Lam,

    I know this is a different topic, but I would like to know if it is possible to access ovf properties from vRA 8 blueprints? I have been trying to inject userdata metadata through guestinfo properties without any luck. Any help will be greatly appreciated.

    Regards

    Reply
    • William Lam says

      10/17/2020 at 6:57 am

      Sorry, I don’t work with vRA so I can’t say what it can or can’t do.

      Reply
  6. anass bekar says

    11/26/2020 at 5:09 am

    doesn’t terraform need a vmdk file to deploy from a local ovf?

    Reply
  7. Jose Garces says

    01/28/2021 at 12:33 pm

    Did you test this on vSphere 7?

    On the GitHub vSphere Provider for Terraform repository it mention that one of the requirements is vSphere 6.5

    “Currently, this provider is not tested for vSphere 7, but plans are underway to add support.”

    Reply
  8. Jan Andel says

    02/23/2021 at 11:44 pm

    Cant get this to working, when using exactly your example, the Nested ESXi gets deployed, but with 1gb ram and doesnt boot, when I specify 4GB of ram, it boots without NIC, when i specify to add NIC, it boots ok but none of the vapp config is applied, any idea what could cause this? running it against vcenter 7.0d

    Reply
    • Jan Andel says

      02/24/2021 at 4:26 am

      so, it seems that the initial VM is OK with all config, but once terraform does reconfiguration in vCenter, it sets it to 1cpu, 1gb ram and removes networking.

      Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Services Business Unit (CSBU) at VMware. He focuses on Automation, Integration and Operation for the VMware Cloud Software Defined Datacenters (SDDC)

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Sponsors

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy