data "template_file" "user_data" { count = var.node_count template = file("${path.module}/files/user_data.cfg") vars = { pubkey = file("~/.ssh/id_rsa.pub") } } data "template_file" "meta_data" { count = var.node_count template = file("${path.module}/files/meta_data.cfg") vars = { hostname = "swarm-${count.index + 1}" } } resource "libvirt_cloudinit_disk" "cidata" { count = var.node_count name = "swarm-${count.index + 1}-cidata.iso" user_data = data.template_file.user_data[count.index].rendered meta_data = data.template_file.meta_data[count.index].rendered }