The Issue
When using Terraform to deploy a virtual machine OVA using Terraform, I kept hitting the below error:
Error: error while creating vapp properties config unsupported vApp properties in vapp.properties: [vm.vmname vami.gateway.DMS_agent_VA vami.netmask0.DMS_Agent_VA vami.DNS.DMS_Agent_VA vami.searchpath.DMS_Agent_VA vami.ip0.DMS_Agent_VA vami.domain.DMS_Agent_VA]
on Agent_appliance/main.tf line 20, in resource "vsphere_virtual_machine" "vm":
20: resource "vsphere_virtual_machine" "vm"
Pretty simple right? In my Terraform file I was trying to use OVF Properties that were not valid. Getting the debug/trace logs from terraform also just showed the same error output.
However running ovftool, confirmed my properties were correct. (shortened output example).
ClassId: vami
Key: searchpath
InstanceId DMS_Agent_VA
Category: Networking Properties
Label: Domain Search Path
Type: string
Description: The domain search path (comma or space separated domain names)
for this VM. Leave blank if DHCP is desired.
But also in the vCenter UI, looking at the vApp Properties of a the OVA once deployed, again I could validate the the properties I was using were correct.
Finally an example of the vSphere_virtual_machine resource I was trying to deploy that was causing me issues:
resource "vsphere\_virtual\_machine" "vm" {
name = "${var.agent\_vm\_name}"
resource_pool_id = "${var.resource\_pool\_id}"
datastore_id = "${data.vsphere\_datastore.datastore.id}"
folder = "${var.folder}"
wait_for_guest_net_timeout = 0
wait_for_guest_ip_timeout = 0
datacenter_id = "${data.vsphere\_datacenter.dc.id}"
host_system_id = "${data.vsphere\_host.host.id}"
dynamic "ovf\_deploy" {
for_each = "${var.agent\_local\_ovf\_path}" != "" || "${var.agent\_remote\_ovf\_path}" != "" ? [0] : []
content {
// Path to local or remote ovf/ova file
local_ovf_path = "${var.agent\_local\_ovf\_path}" != "" ? "${var.agent\_local\_ovf\_path}" : null
remote_ovf_url = "${var.agent\_remote\_ovf\_path}" != "" ? "${var.agent\_remote\_ovf\_path}" : null
disk_provisioning = "thin"
ovf_network_map = {
"Control Plane Network" = data.vsphere\_network.network.id
}
}
}
vapp {
properties = {
"vm.vmname" = "${var.agent\_vm\_name}",
"varoot_password" = "${var.varoot\_password}",
"vaadmin_password" = "${var.va\_admin\_password}",
"guestinfo.cis.appliance.net.ntp" = "${var.ntp}",
"vami.gateway.DMS_agent_VA" = "${var.controlplanenetworkgateway}",
"vami.DNS.DMS_Agent_VA" = "${var.dns}",
"vami.domain.DMS_Agent_VA" = "${var.domain}",
"vami.searchpath.DMS_Agent_VA" = "${var.searchpath}",
"vami.ip0.DMS_Agent_VA" = "${var.agentip0}",
"vami.netmask0.DMS_Agent_VA" = "${var.agentip0netmask}"
}
}
}
The Cause
Yep, you guessed it, there was something wrong with the properties I was trying to configure.
The Fix
After testing a number of ways to validate the OVF Properties expected, I came across a blog from William Lam, where he produced a PowerShell script that calls the vSphere API for the OVF Properties of a given VM.
Running his Powershell script against a deployed copy of the OVA, I noticed the return values were not the same as in the vCenter UI.
So I changed the Terraform files to use the values I seen below, ran again and success!
I’ve dropped a note to the team behind the provider about this to see if its the expected behaviour.
I also logged this issue and closed it in GitHub here.
And finally, if you want to check out the Terraform module I was building to Deploy Data Management for Tanzu, you can find it here.
The Cause
Regards
The post Terraform vSphere Provider – Error while creating vApp properties appeared first on vEducate.co.uk.
Top comments (0)