2020-07-28 21:45:32 +00:00
|
|
|
# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/domain.html.markdown
|
|
|
|
|
|
|
|
# Define KVM domain to create
|
|
|
|
|
2021-01-31 14:53:46 +00:00
|
|
|
resource "libvirt_domain" "controllers" {
|
2021-01-23 20:45:22 +00:00
|
|
|
name = format("db%s", count.index)
|
2021-01-31 14:53:46 +00:00
|
|
|
memory = "2048"
|
|
|
|
vcpu = 2
|
2020-08-05 22:34:05 +00:00
|
|
|
running = "true"
|
2020-07-28 21:45:32 +00:00
|
|
|
autostart = "true"
|
|
|
|
|
2021-01-31 14:53:46 +00:00
|
|
|
count = var.number_controller
|
2021-01-24 20:49:30 +00:00
|
|
|
qemu_agent = true
|
2021-01-23 20:45:22 +00:00
|
|
|
|
2020-07-28 21:45:32 +00:00
|
|
|
boot_device {
|
|
|
|
dev = ["hd", "network"]
|
|
|
|
}
|
|
|
|
|
|
|
|
network_interface {
|
2021-01-24 23:12:17 +00:00
|
|
|
network_id = libvirt_network.private_network.id
|
|
|
|
hostname = format("compute-%s", count.index)
|
2020-07-28 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
2021-01-31 12:19:45 +00:00
|
|
|
volume_id = libvirt_volume.root_debian[count.index].id
|
2020-07-28 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 23:05:35 +00:00
|
|
|
disk {
|
2021-01-31 12:19:45 +00:00
|
|
|
volume_id = libvirt_volume.external_disk[count.index].id
|
2020-08-10 23:05:35 +00:00
|
|
|
}
|
2020-07-28 21:45:32 +00:00
|
|
|
|
2021-01-23 20:45:22 +00:00
|
|
|
cloudinit = libvirt_cloudinit_disk.commoninit[count.index].id
|
2020-07-28 21:45:32 +00:00
|
|
|
|
|
|
|
console {
|
|
|
|
type = "pty"
|
|
|
|
target_type = "serial"
|
|
|
|
target_port = "0"
|
|
|
|
}
|
|
|
|
|
|
|
|
graphics {
|
|
|
|
type = "vnc"
|
|
|
|
listen_type = "address"
|
|
|
|
autoport = "true"
|
|
|
|
}
|
|
|
|
}
|
2021-01-31 14:53:46 +00:00
|
|
|
|
|
|
|
resource "libvirt_domain" "workers" {
|
|
|
|
name = format("db%s", var.number_controller + count.index)
|
|
|
|
memory = "1024"
|
|
|
|
vcpu = 1
|
|
|
|
running = "true"
|
|
|
|
autostart = "true"
|
|
|
|
|
|
|
|
count = var.number_worker
|
|
|
|
qemu_agent = true
|
|
|
|
|
|
|
|
boot_device {
|
|
|
|
dev = ["hd", "network"]
|
|
|
|
}
|
|
|
|
|
|
|
|
network_interface {
|
|
|
|
network_id = libvirt_network.private_network.id
|
|
|
|
hostname = format("compute-%s", var.number_controller + count.index)
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
|
|
volume_id = libvirt_volume.root_debian[var.number_controller + count.index].id
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
|
|
volume_id = libvirt_volume.external_disk[var.number_controller + count.index].id
|
|
|
|
}
|
|
|
|
|
|
|
|
cloudinit = libvirt_cloudinit_disk.commoninit[var.number_controller + count.index].id
|
|
|
|
|
|
|
|
console {
|
|
|
|
type = "pty"
|
|
|
|
target_type = "serial"
|
|
|
|
target_port = "0"
|
|
|
|
}
|
|
|
|
|
|
|
|
graphics {
|
|
|
|
type = "vnc"
|
|
|
|
listen_type = "address"
|
|
|
|
autoport = "true"
|
|
|
|
}
|
|
|
|
}
|