terraform-k8s/roles/terraform/templates/terraform-libvirt-domain.tf.j2

49 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2019-01-22 12:10:16 +00:00
resource "libvirt_domain" "domain-{{ item.hostname }}" {
name = "{{ item.hostname }}"
2019-01-22 14:28:46 +00:00
memory = "{{ item.memory }}"
vcpu = "{{ item.vcpu }}"
2019-01-22 12:10:16 +00:00
cloudinit = "${libvirt_cloudinit_disk.cloud-init-{{ item.hostname }}.id}"
network_interface {
2019-01-22 14:28:46 +00:00
bridge = "{{ libvirt_network_bridge }}"
2019-01-22 12:10:16 +00:00
mac = "{{ item.mac_address }}"
}
boot_device {
dev = ["hd"]
}
disk {
2019-01-22 14:28:46 +00:00
volume_id = "${libvirt_volume.{{ item.hostname }}.id}"
2019-01-22 12:10:16 +00:00
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
2019-01-25 18:04:04 +00:00
}
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")}"
}