iac/terraform/dos/demo-server.tf

52 lines
1.5 KiB
Terraform
Raw Permalink Normal View History

# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
resource "libvirt_volume" "mcaptcha_demo_server_volume" {
name = "mcaptcha_demo_server_volume-${count.index}"
base_volume_id = libvirt_volume.debian-mcaptcha-qcow2.id
count = var.mcaptcha_demo_server_vm_count
pool = libvirt_pool.mcaptcha_basic.name
size = var.mcaptcha_demo_server_vm_disk_size
}
resource "libvirt_domain" "mcaptcha_demo_server" {
count = var.mcaptcha_demo_server_vm_count
name = "mcaptcha_mcaptcha_demo_server_${count.index}"
memory = var.mcaptcha_demo_server_vm_memory
vcpu = var.mcaptcha_demo_server_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_demo_server_volume.*.id, count.index)
}
}
locals {
mcaptcha_demo_server_vm_ips = [for i in libvirt_domain.mcaptcha_demo_server : i.network_interface.0.addresses[0]]
mcaptcha_demo_server_vm_names = [for i in libvirt_domain.mcaptcha_demo_server : i.name]
mcaptcha_demo_server_vm_map = [for i in libvirt_domain.mcaptcha_demo_server : {
ip = i.network_interface.0.addresses[0],
name = i.name
}]
}