Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

terraform - Deploy virtual machine cloning OVF/OVA from datastore vsphere

I read documentation https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs/resources/virtual_machine#using-vapp-properties-to-supply-ovf-ova-configuration and few tutorials about cloning machine from an OVF/OVA-created template with vApp properties and I always read about local path to ovf template or they just put name of template in variables and that works like there https://blog.inkubate.io/create-a-centos-7-terraform-template-for-vmware-vsphere/. Where Terraform search for template? What if I have template in some datastore? What should I write in this part of my file?

data "vsphere_datastore" "datastore" {
  name          = "my_best_datastore"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_virtual_machine" "template_from_ovf" {
  name          = "template_from_ovf"  ---what should be there? Path like /dc/datastore/somefile or only name?
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
question from:https://stackoverflow.com/questions/65851868/deploy-virtual-machine-cloning-ovf-ova-from-datastore-vsphere

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The VM data source object is looking for the name of the template as it shows through either the UI or the API as well as the datacenter ID it resides in. That means that the template must be registered to the vSphere environment and that it cannot search datastores for the desired OVA/OVF files.

More info on what the vsphere-virtual-machine data source can be found: here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...