53 lines
1.1 KiB
Terraform
53 lines
1.1 KiB
Terraform
|
terraform {
|
||
|
backend "pg" {
|
||
|
schema_name = "dmz_dns"
|
||
|
}
|
||
|
|
||
|
required_providers {
|
||
|
libvirt = {
|
||
|
source = "dmacvicar/libvirt"
|
||
|
}
|
||
|
template = {
|
||
|
source = "hashicorp/template"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
provider "libvirt" {
|
||
|
uri = var.libvirt_endpoint
|
||
|
}
|
||
|
|
||
|
resource "libvirt_volume" "main_disk" {
|
||
|
name = "${var.name}.iso"
|
||
|
pool = "disk"
|
||
|
size = 1024 * 1024 * 1024 * 15
|
||
|
base_volume_name = "debian-bookworm.qcow2"
|
||
|
base_volume_pool = "iso"
|
||
|
}
|
||
|
|
||
|
resource "libvirt_cloudinit_disk" "cloudinit" {
|
||
|
name = "${var.name}.iso"
|
||
|
pool = "init"
|
||
|
user_data = templatefile("cloud_init.cfg.tftpl", { name = var.name, host_public_key = var.host_public_key })
|
||
|
network_config = templatefile("network_config.cfg.tftpl", {})
|
||
|
}
|
||
|
|
||
|
resource "libvirt_domain" "ubuntu" {
|
||
|
name = var.name
|
||
|
memory = 1024
|
||
|
vcpu = 4
|
||
|
|
||
|
disk {
|
||
|
volume_id = libvirt_volume.main_disk.id
|
||
|
}
|
||
|
|
||
|
network_interface {
|
||
|
network_name = "dmzbr"
|
||
|
hostname = var.name
|
||
|
addresses = ["192.168.30.7/24"]
|
||
|
mac = "ca:fe:c0:ff:ee:07"
|
||
|
}
|
||
|
|
||
|
cloudinit = libvirt_cloudinit_disk.cloudinit.id
|
||
|
}
|