Hi all,
I have a VM module to create a new VM. I have exposed the computed mac_address via output like so:
output "mac" {
value = "${vsphere_virtual_machine.vm.network_interface[0].mac_address}"
}
Then the root module, I needed to pass this mac address to another module, that has variable “mac” as string:
module "system" {
source = "./modules/cobbler/system_local_exec"
for_each = local.vms
name = each.key
profile = each.value.profile
hostname = each.key
netboot = local.netboot
interface = each.value.nic
mac = "${module.vm.mac}"
ip = each.value.ip
netmask = local.netmask
dhcp_tag = local.dhcp_tag
dns_name = format("%s.%s", each.key, local.domain)
gateway = local.gateway
static = local.static
comment = local.comment
}
It seems to be very straightforward but it does not work for me, I am getting:
$ terraform plan
╷
│ Error: Invalid value for input variable
│
│ on main.tf line 42, in module "system":
│ 42: mac = "${module.vm.mac}"
│
│ The given value is not suitable for module.system.var.mac declared at ../../modules/cobbler/system_local_exec/variables.tf:49,1-15: string required.
╵
I am wondering what the mistake is?
Thanks in advance.
Cheers
D