terraform-libvirt/stack/cloud_init.tf

26 lines
722 B
HCL

data "template_file" "user_data" {
template = file(format("%s/cloud_init_user_data.yml", path.module))
vars = {
hostname = format("%s-%s", var.hostname, count.index)
}
count = local.number_domain
}
data "template_file" "meta_data" {
template = file(format("%s/cloud_init_meta_data.yml", path.module))
vars = {
instance_id = count.index
}
count = local.number_domain
}
# Use CloudInit to add the instance
resource "libvirt_cloudinit_disk" "commoninit" {
name = format("commoninit-%s.iso", count.index)
pool = var.pool_1
user_data = data.template_file.user_data[count.index].rendered
meta_data = data.template_file.meta_data[count.index].rendered
count = local.number_domain
}