terraform-libvirt/stack/computes.tf

88 lines
1.8 KiB
HCL

# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/domain.html.markdown
# Define KVM domain to create
resource "libvirt_domain" "controllers" {
name = format("db%s", count.index)
memory = "2048"
vcpu = 2
running = "true"
autostart = "true"
count = var.number_controller
qemu_agent = true
boot_device {
dev = ["hd", "network"]
}
network_interface {
network_id = libvirt_network.private_network.id
hostname = format("compute-%s", count.index)
}
disk {
volume_id = libvirt_volume.root_debian[count.index].id
}
disk {
volume_id = libvirt_volume.external_disk[count.index].id
}
cloudinit = libvirt_cloudinit_disk.commoninit[count.index].id
console {
type = "pty"
target_type = "serial"
target_port = "0"
}
graphics {
type = "vnc"
listen_type = "address"
autoport = "true"
}
}
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"
}
}