replace count by for_each with declared set
This commit is contained in:
parent
3e5d65773c
commit
a5e79eaba7
@ -1,13 +1,13 @@
|
||||
module "pve_vm" {
|
||||
source = "../../modules/pve_vm"
|
||||
count = 2
|
||||
node_name = "zenith"
|
||||
vm_name = "zenith-vm-${count.index + 1}"
|
||||
vm_cpu = 2
|
||||
vm_ram = 2048
|
||||
vm_vlan = 66
|
||||
source = "../../modules/pve_vm"
|
||||
for_each = var.node_list
|
||||
node_name = each.value
|
||||
vm_name = "${each.value}-vm"
|
||||
vm_cpu = 2
|
||||
vm_ram = 2048
|
||||
vm_vlan = 66
|
||||
}
|
||||
|
||||
output "vm_ip" {
|
||||
value = module.pve_vm[*].vm_ip
|
||||
value = { for k, v in module.pve_vm : "${k}-vm" => v.vm_ip }
|
||||
}
|
@ -7,4 +7,10 @@ variable "proxmox_api_token" {
|
||||
description = "Proxmox API token"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "node_list" {
|
||||
description = "List of node names in the Proxmox cluster"
|
||||
type = set(string)
|
||||
default = ["apex", "vertex", "zenith"]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user