55 lines
1.2 KiB
Plaintext
55 lines
1.2 KiB
Plaintext
|
resource "libvirt_cloudinit_disk" "cloud-init-{{ item.hostname }}" {
|
||
|
name = "cloud-init-{{ item.hostname }}.iso"
|
||
|
pool = "kubernetes"
|
||
|
user_data = "${data.template_file.user-data-{{ item.hostname }}.rendered}"
|
||
|
}
|
||
|
|
||
|
data "template_file" "user-data-{{ item.hostname }}" {
|
||
|
template = "${file("${path.module}/{{ item.hostname }}.cloud_init.cfg")}"
|
||
|
}
|
||
|
|
||
|
resource "libvirt_volume" "centos-7-generic-{{ item.hostname }}" {
|
||
|
name = "centos-7-generic-{{ item.hostname }}"
|
||
|
source = "CentOS-7-x86_64-GenericCloud.qcow2"
|
||
|
pool = "kubernetes"
|
||
|
format = "qcow2"
|
||
|
}
|
||
|
|
||
|
resource "libvirt_domain" "domain-{{ item.hostname }}" {
|
||
|
name = "{{ item.hostname }}"
|
||
|
memory = "1024"
|
||
|
vcpu = 1
|
||
|
|
||
|
cloudinit = "${libvirt_cloudinit_disk.cloud-init-{{ item.hostname }}.id}"
|
||
|
|
||
|
console {
|
||
|
type = "pty"
|
||
|
target_port = "0"
|
||
|
target_type = "serial"
|
||
|
}
|
||
|
|
||
|
console {
|
||
|
type = "pty"
|
||
|
target_type = "virtio"
|
||
|
target_port = "1"
|
||
|
}
|
||
|
|
||
|
network_interface {
|
||
|
bridge = "home-lan"
|
||
|
mac = "{{ item.mac_address }}"
|
||
|
}
|
||
|
|
||
|
boot_device {
|
||
|
dev = ["hd"]
|
||
|
}
|
||
|
|
||
|
disk {
|
||
|
volume_id = "${libvirt_volume.centos-7-generic-{{ item.hostname }}.id}"
|
||
|
}
|
||
|
|
||
|
graphics {
|
||
|
type = "spice"
|
||
|
listen_type = "address"
|
||
|
autoport = true
|
||
|
}
|
||
|
}
|