iac/terraform/dos/main.tf

46 lines
1.1 KiB
HCL

# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
terraform {
required_version = ">= 0.13"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "~> 0.7.0"
}
}
}
provider "libvirt" {
uri = var.libvirt_uri
}
resource "libvirt_pool" "mcaptcha_basic" {
name = "mcaptcha_basic"
type = "dir"
path = var.libvirt_pool_path
}
resource "libvirt_volume" "debian-mcaptcha-qcow2" {
name = "debian-mcaptcha-qcow2"
pool = libvirt_pool.mcaptcha_basic.name
source = var.libvirt_debian_src
format = "qcow2"
}
data "template_file" "user_data" {
template = file("${path.module}/cloud_init.cfg")
}
data "template_file" "network_config" {
template = file("${path.module}/network_config.cfg")
}
resource "libvirt_cloudinit_disk" "commoninit" {
name = "commoninit.iso"
user_data = data.template_file.user_data.rendered
network_config = data.template_file.network_config.rendered
pool = libvirt_pool.mcaptcha_basic.name
}