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-23 20:45:22 +00:00
|
|
|
resource "libvirt_domain" "domains" {
|
|
|
|
name = format("db%s", count.index)
|
2020-07-28 21:45:32 +00:00
|
|
|
memory = "1024"
|
|
|
|
vcpu = 1
|
2020-08-05 22:34:05 +00:00
|
|
|
running = "true"
|
2020-07-28 21:45:32 +00:00
|
|
|
autostart = "true"
|
|
|
|
|
2021-01-24 20:49:30 +00:00
|
|
|
count = var.number_domain
|
|
|
|
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 {
|
2020-08-05 22:34:05 +00:00
|
|
|
network_name = libvirt_network.private_network.name
|
2020-07-28 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
2021-01-23 20:45:22 +00:00
|
|
|
volume_id = element(libvirt_volume.root_debian.*.id, count.index)
|
2020-07-28 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 23:05:35 +00:00
|
|
|
disk {
|
2021-01-23 20:45:22 +00:00
|
|
|
volume_id = element(libvirt_volume.external_disk.*.id, count.index)
|
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"
|
|
|
|
}
|
|
|
|
}
|