2023-11-15 16:43:00 +05:30
|
|
|
# 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")
|
2023-12-12 19:32:24 +05:30
|
|
|
vars = {
|
|
|
|
ssh_public_key = var.ssh_public_key
|
|
|
|
}
|
2023-11-15 16:43:00 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|