In have the following variable:
variable "virtual_machines" {
default = {
"master1" = {
name = "z-ca-bdc-master1"
worker_node = false
ipv4_address = "192.168.113.79"
ipv4_netmask = "22"
ipv4_gateway = "192.168.112.1"
dns_server = "192.168.112.2"
ram = 8192
logical_cpu = 4
disk0_size = 40
disk1_size = 0
},
"master2" = {
name = "z-ca-bdc-master2"
worker_node = false
ipv4_address = "192.168.113.80"
ipv4_netmask = "22"
ipv4_gateway = "192.168.112.1"
dns_server = "192.168.112.2"
ram = 8192
logical_cpu = 4
disk0_size = 40
disk1_size = 0
},
And I would like to iterate through this in order to use the element worker_node and name in a template, this is the code I’m using which is clearly wrong because terraform plan spits it out:
data "template_file" "k8s" {
template = file("./templates/kubespray_inventory.tpl")
vars = {
k8s_master_name = join("\n", var.virtual_machines.worker_node ? "" : var.virtual_machines.name)
k8s_node_host = join("\n", var.virtual_machines.name)
}
}
Can someone tell me what the correct syntax is that I should be using in place of var.virtual_machines.worker_node and var.virtual_machines.name.