Terraform vSphere官方提供商,使用OVF_Deploy创建VM
我是韩国工人,他使用Terraform代码使用官方Terraform vSphere提供商在vCenter中提供虚拟机。
我目前正在使用OVF模板配置VM,因此我尝试配置具有OVF文件的数据存储路径的“远程_ovf_url”。
但是看来“远程_ovf_url”参数并不意味着vCenter的数据存储文件夹路径。
我猜是对吗?如果不是这样,我该如何找到数据存储的“远程_url_path”?
Vsphere提供商是否不支持通过vCenter的内容库或数据存储上的OVF文件来创建虚拟机?
data "vsphere_datacenter" "datacenter" {
name = "Datacenter"
}
data "vsphere_compute_cluster" "cluster" {
name = "새 클러스터"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_datastore" "datastore" {
name = "datastore1"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_host" "host" {
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_network" "network" {
name = "VM Network"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_ovf_vm_template" "ovf" {
name = "terraform-ovf-vm"
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
host_system_id = data.vsphere_host.host.id
datastore_id = data.vsphere_datastore.datastore.id
# remote_ovf_url = "https://10.1.0.153/cls/data/293ed829-9178-4ee7-a0bf-8b57b216e423/linux-mint-2.ovf" # when export ovf, I copied its url
# remote_ovf_url = "https://10.1.0.153/ui/data/properties/urn:vmomi:Folder:group-d1:8f6de25d-8ed0-4032-b90e-b762588f4801?properties=libraryTemplates" # developer tool's (F12)
remote_ovf_url = "https://10.1.0.153/ui/app/datastore;nav=s/urn:vmomi:Datastore:datastore-15:8f6de25d-8ed0-4032-b90e-b762588f4801/files/220707_2bae2c91-0496-484c-862b-313fa67022a6.ovf" # just entered the vcenter web ui and attached ovf file to '.../files/'
} # I tried all of the tries above, but failed.
resource "vsphere_virtual_machine" "vm" {
name = "terraform-vm-ha101"
datacenter_id = data.vsphere_datacenter.datacenter.id
host_system_id = data.vsphere_host.host.id
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = 1
memory = 1024
guest_id = "otherLinux64Guest"
wait_for_guest_net_timeout = 0
network_interface {
network_id = data.vsphere_network.network.id
}
ovf_deploy {
allow_unverified_ssl_cert = false
remote_ovf_url = data.vsphere_ovf_vm_template.ovf.remote_ovf_url
disk_provisioning = "thin"
ip_protocol = "IPV4"
ip_allocation_policy = "STATIC_MANUAL"
ovf_network_map = {
"Network 1" = data.vsphere_network.network.id
"Network 2" = data.vsphere_network.network.id
}
}
disk {
label = "disk0"
size = 16
thin_provisioned = false
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Terraform vSphere提供商确实通过使用 vsphere_virtual_machine资源使用。
如果需要将参数指定到OVF,则可以使用 VAPP选项。
The Terraform vSphere provider does support the creation of a virtual machine using OVF from a content library by using the vsphere_virtual_machine resource with the clone option.
If you need to specify parameters to the OVF, you can use the vApp option.