Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...