terraform-libvirt/stack/cloud_init.tf

26 lines
722 B
Terraform
Raw Normal View History

data "template_file" "user_data" {
template = file(format("%s/cloud_init_user_data.yml", path.module))
vars = {
2021-01-23 20:45:22 +00:00
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 = {
2021-01-23 20:45:22 +00:00
instance_id = count.index
}
count = local.number_domain
}
# Use CloudInit to add the instance
resource "libvirt_cloudinit_disk" "commoninit" {
2021-01-23 20:45:22 +00:00
name = format("commoninit-%s.iso", count.index)
pool = var.pool_1
2021-01-23 20:45:22 +00:00
user_data = data.template_file.user_data[count.index].rendered
meta_data = data.template_file.meta_data[count.index].rendered
count = local.number_domain
}