2023-11-15 16:43:00 +05:30
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
resource "libvirt_volume" "mcaptcha_volume" {
|
|
|
|
name = "mcaptcha_volume-${count.index}"
|
|
|
|
base_volume_id = libvirt_volume.debian-mcaptcha-qcow2.id
|
|
|
|
count = var.mcaptcha_vm_count
|
|
|
|
pool = libvirt_pool.mcaptcha_basic.name
|
|
|
|
size = var.mcaptcha_vm_disk_size
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "libvirt_domain" "mcaptcha_mcaptcha" {
|
|
|
|
count = var.mcaptcha_vm_count
|
|
|
|
|
2023-12-12 19:34:05 +05:30
|
|
|
name = "mcaptcha_mcaptcha_${count.index}"
|
|
|
|
memory = var.mcaptcha_vm_memory
|
|
|
|
vcpu = var.mcaptcha_vm_vcpu
|
|
|
|
qemu_agent = true
|
2023-11-15 16:43:00 +05:30
|
|
|
|
|
|
|
cloudinit = libvirt_cloudinit_disk.commoninit.id
|
|
|
|
|
|
|
|
console {
|
|
|
|
type = "pty"
|
|
|
|
target_port = "0"
|
|
|
|
target_type = "serial"
|
|
|
|
}
|
|
|
|
|
|
|
|
console {
|
|
|
|
type = "pty"
|
|
|
|
target_type = "virtio"
|
|
|
|
target_port = "1"
|
|
|
|
}
|
|
|
|
|
2023-12-12 19:34:05 +05:30
|
|
|
|
2023-11-15 16:43:00 +05:30
|
|
|
network_interface {
|
2023-12-12 19:34:05 +05:30
|
|
|
macvtap = var.macvtap_ethernet_interface
|
2023-11-15 16:43:00 +05:30
|
|
|
wait_for_lease = true
|
|
|
|
}
|
|
|
|
|
|
|
|
disk {
|
|
|
|
volume_id = element(libvirt_volume.mcaptcha_volume.*.id, count.index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-12 19:34:05 +05:30
|
|
|
|
|
|
|
|
2023-11-15 16:43:00 +05:30
|
|
|
locals {
|
|
|
|
mcaptcha_vm_ips = [for i in libvirt_domain.mcaptcha_mcaptcha : i.network_interface.0.addresses[0]]
|
|
|
|
mcaptcha_vm_names = [for i in libvirt_domain.mcaptcha_mcaptcha : i.name]
|
|
|
|
mcaptcha_vm_map = [for i in libvirt_domain.mcaptcha_mcaptcha : {
|
|
|
|
ip = i.network_interface.0.addresses[0],
|
|
|
|
name = i.name
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|