terraform-k8s/roles/terraform/files/cloud-init.tf.j2
2019-01-25 19:04:04 +01:00

50 lines
1.3 KiB
Django/Jinja

resource "libvirt_domain" "domain-{{ item.hostname }}" {
name = "{{ item.hostname }}"
memory = "{{ item.memory }}"
vcpu = "{{ item.vcpu }}"
cloudinit = "${libvirt_cloudinit_disk.cloud-init-{{ item.hostname }}.id}"
network_interface {
bridge = "{{ libvirt_network_bridge }}"
mac = "{{ item.mac_address }}"
}
boot_device {
dev = ["hd"]
}
disk {
volume_id = "${libvirt_volume.{{ item.hostname }}.id}"
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
}
resource "libvirt_volume" "{{ item.hostname }}" {
name = "{{ item.hostname }}"
source = "{{ source_cloud_image_name }}"
pool = "{{ libvirt_storage_pool }}"
format = "qcow2"
}
resource "libvirt_cloudinit_disk" "cloud-init-{{ item.hostname }}" {
name = "cloud-init-{{ item.hostname }}.iso"
pool = "{{ libvirt_storage_pool }}"
user_data = "${data.template_file.user-data-{{ item.hostname }}.rendered}"
network_config = "${data.template_file.network-config-{{ item.hostname }}.rendered}"
}
data "template_file" "user-data-{{ item.hostname }}" {
template = "${file("${path.module}/{{ item.hostname }}.cloud_init.cfg")}"
}
data "template_file" "network-config-{{ item.hostname }}" {
template = "${file("${path.module}/{{ item.hostname }}.cloud_init_network.cfg")}"
}