diff --git a/modules/vmware/main.tf b/modules/vmware/main.tf index 9c16261..6ac3e38 100644 --- a/modules/vmware/main.tf +++ b/modules/vmware/main.tf @@ -1,39 +1,3 @@ -variable "vms" { - type = map(object( - { - domain = string - cpu = number - ram = number - guest_id = string - disks = map(object({ - size = string - })) - network_interfaces = list(object( - { - id = string - mac = string - } - )) - folder = string - } - )) - description = "Virtual Machines description" -} - -variable "cluster" { - type = object({ - datacenter_name = string - datastore_name = string - resource_pool_name = string - folder = string - vnets = map(object({ - name = string - })) - } - ) - description = "vSphere cluster definition" -} - data "vsphere_datacenter" "datacenter" { name = var.cluster.datacenter_name } @@ -48,6 +12,11 @@ data "vsphere_resource_pool" "pool" { datacenter_id = data.vsphere_datacenter.datacenter.id } +data "vsphere_host" "host" { + name = "10.253.10.50" + datacenter_id = data.vsphere_datacenter.datacenter.id +} + data "vsphere_network" "network" { for_each = var.cluster.vnets @@ -81,6 +50,34 @@ resource "vsphere_virtual_machine" "vm" { content { label = disk.key size = disk.value.size + thin_provisioned = disk.thin_provisioned + unit_number = disk.unit_number } } +} + +resource "vsphere_virtual_machine" "ova" { + for_each = var.ovfs + name = "${each.key}.${each.value.domain}" + resource_pool_id = data.vsphere_resource_pool.pool.id + datastore_id = data.vsphere_datastore.datastore.id + host_system_id = data.vsphere_host.host.id + folder = var.cluster.folder + + wait_for_guest_net_timeout = 0 + wait_for_guest_ip_timeout = 0 + + ovf_deploy { + allow_unverified_ssl_cert = each.value.allow_unverified_ssl_cert + remote_ovf_url = each.value.remote_ovf_url + disk_provisioning = each.value.disk_provisioning + ip_protocol = each.value.ip_protocol + ip_allocation_policy = each.value.ip_allocation_policy + ovf_network_map = { + "Network 1" = data.vsphere_network.network[each.value.network_map[0]].id + } + } + vapp { + properties = each.value.vapp_properties + } } \ No newline at end of file diff --git a/modules/vmware/version.tf b/modules/vmware/version.tf index da87832..4e10be7 100644 --- a/modules/vmware/version.tf +++ b/modules/vmware/version.tf @@ -2,7 +2,7 @@ terraform { required_providers { vsphere = { source = "hashicorp/vsphere" - version = "~> 2.4.0" + version = "~> 2.5.1" } } } \ No newline at end of file