iac/terraform/dos/dos.tf

51 lines
1.3 KiB
HCL

# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
resource "libvirt_volume" "mcaptcha_dos_volume" {
name = "mcaptcha_dos_volume-${count.index}"
base_volume_id = libvirt_volume.debian-mcaptcha-qcow2.id
count = var.mcaptcha_dos_vm_count
pool = libvirt_pool.mcaptcha_basic.name
size = var.mcaptcha_dos_vm_disk_size
}
resource "libvirt_domain" "mcaptcha_dos" {
count = var.mcaptcha_dos_vm_count
name = "mcaptcha_mcaptcha_dos_${count.index}"
memory = var.mcaptcha_dos_vm_memory
vcpu = var.mcaptcha_dos_vm_vcpu
cloudinit = libvirt_cloudinit_disk.commoninit.id
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
console {
type = "pty"
target_type = "virtio"
target_port = "1"
}
network_interface {
network_name = "default"
wait_for_lease = true
}
disk {
volume_id = element(libvirt_volume.mcaptcha_dos_volume.*.id, count.index)
}
}
locals {
mcaptcha_dos_vm_ips = [for i in libvirt_domain.mcaptcha_dos : i.network_interface.0.addresses[0]]
mcaptcha_dos_vm_names = [for i in libvirt_domain.mcaptcha_dos : i.name]
mcaptcha_dos_vm_map = [for i in libvirt_domain.mcaptcha_dos : {
ip = i.network_interface.0.addresses[0],
name = i.name
}]
}