terraform-libvirt/stack/cloud_init.tf

26 lines
708 B
Terraform
Raw Normal View History

data "template_file" "user_data" {
template = "${file("${path.module}/cloud_init_user_data.yml")}"
vars = {
2021-01-23 20:45:22 +00:00
hostname = format("%s-%s", var.hostname, count.index)
}
2021-01-23 20:45:22 +00:00
count = var.number_domain
}
data "template_file" "meta_data" {
template = "${file("${path.module}/cloud_init_meta_data.yml")}"
vars = {
2021-01-23 20:45:22 +00:00
instance_id = count.index
}
2021-01-23 20:45:22 +00:00
count = var.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 = var.number_domain
}