fix(vmware): adding name param to network definitions
This commit is contained in:
parent
0fad70363b
commit
eae0dbce65
|
@ -5,17 +5,15 @@ variable "vms" {
|
|||
cpu = number
|
||||
ram = number
|
||||
guest_id = string
|
||||
disks = list(object({
|
||||
name = string
|
||||
disks = map(object({
|
||||
size = string
|
||||
}))
|
||||
network_interfaces = map(object(
|
||||
{
|
||||
name = string
|
||||
mac = string
|
||||
}
|
||||
))
|
||||
resource_pool_id = string
|
||||
datastore_id = string
|
||||
folder = string
|
||||
}
|
||||
))
|
||||
|
@ -23,14 +21,13 @@ variable "vms" {
|
|||
}
|
||||
|
||||
variable "cluster" {
|
||||
type = map(object(
|
||||
{
|
||||
type = object({
|
||||
datacenter_name = string
|
||||
datastore_name = string
|
||||
resource_pool_name = string
|
||||
folder = string
|
||||
}
|
||||
))
|
||||
)
|
||||
description = "vSphere cluster definition"
|
||||
}
|
||||
|
||||
|
@ -51,16 +48,16 @@ data "vsphere_resource_pool" "pool" {
|
|||
data "vsphere_network" "network" {
|
||||
count = length(var.vms.network_interfaces)
|
||||
|
||||
name = var.networks[count.index].key
|
||||
name = var.networks[count.index].name
|
||||
datacenter_id = data.vsphere_datacenter.datacenter.id
|
||||
}
|
||||
|
||||
resource "vphere_virtual_virtual_machine" "vm" {
|
||||
resource "vsphere_virtual_machine" "vm" {
|
||||
for_each = var.vms
|
||||
iterator = "machine"
|
||||
name = "${machine.key}.${machine.value.domain}"
|
||||
resource_pool_id = "${machine.key.resource_pool_id}"
|
||||
datastore_id = machine.key.datastore_id
|
||||
resource_pool_id = data.vsphere_resource_pool.id
|
||||
datastore_id = data.vsphere_datastore.id
|
||||
folder = machine.folder
|
||||
num_cpus = machine.cpu
|
||||
memory = machine.ram
|
||||
|
@ -76,7 +73,7 @@ resource "vphere_virtual_virtual_machine" "vm" {
|
|||
dynamic "disk" {
|
||||
for_each = each.key.disks
|
||||
content {
|
||||
label = each.key.name
|
||||
label = each.key
|
||||
size = each.key.size
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
opennebula = {
|
||||
source = "hashicorp/vsphere"
|
||||
vsphere = {
|
||||
source = "hashicorp/vsphere"
|
||||
version = "~> 2.4.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue