infrastructure/pve01.wheatley.in/templates/talos/main.tf

79 lines
1.7 KiB
Terraform
Raw Normal View History

2025-11-27 17:08:20 +01:00
terraform {
2025-12-20 19:35:37 +01:00
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.96.0"
2025-12-20 19:35:37 +01:00
}
2025-11-27 17:08:20 +01:00
}
}
2025-11-15 20:49:31 +01:00
data "http" "schematic" {
url = "https://factory.talos.dev/schematics"
method = "POST"
request_body = file("${path.module}/schematic.yaml")
request_headers = {
"Content-Type" = "application/x-yaml"
}
}
locals {
schematic_id = jsondecode(data.http.schematic.response_body)["id"]
storagepool = "nvme-fastpool"
}
2025-11-27 16:37:46 +01:00
resource "proxmox_virtual_environment_download_file" "talos-image" {
2025-12-20 19:35:37 +01:00
for_each = toset(var.talos_versions)
2025-11-15 20:49:31 +01:00
2025-11-27 16:37:46 +01:00
node_name = "pve01"
datastore_id = "local"
content_type = "iso"
2025-11-15 20:49:31 +01:00
2025-12-20 19:35:37 +01:00
url = "https://factory.talos.dev/image/${local.schematic_id}/v${each.value}/nocloud-amd64-secureboot.iso"
file_name = "talos-${each.value}-nocloud-amd64-secureboot.iso"
2025-11-15 20:49:31 +01:00
}
resource "proxmox_virtual_environment_vm" "talos-template" {
2025-11-27 16:37:46 +01:00
depends_on = [proxmox_virtual_environment_download_file.talos-image]
2025-12-20 19:35:37 +01:00
for_each = toset(var.talos_versions)
2025-11-15 20:49:31 +01:00
2025-11-27 16:37:46 +01:00
template = true
vm_id = 10000 + tonumber(replace(each.value, ".", ""))
name = "talos-template-${each.value}"
node_name = "pve01"
tags = ["tofu"]
bios = "ovmf"
on_boot = true
machine = "q35"
2025-11-15 20:49:31 +01:00
operating_system {
type = "l26"
}
agent {
enabled = true
}
cpu {
cores = 2
sockets = 1
2025-12-20 19:35:37 +01:00
type = "host"
2025-11-15 20:49:31 +01:00
}
memory {
dedicated = 2048
}
disk {
datastore_id = local.storagepool
interface = "virtio0"
2025-11-27 16:37:46 +01:00
file_id = proxmox_virtual_environment_download_file.talos-image[each.value].id
2025-11-15 20:49:31 +01:00
file_format = "raw"
}
efi_disk {
datastore_id = local.storagepool
file_format = "raw"
type = "4m"
}
tpm_state {
datastore_id = local.storagepool
version = "v2.0"
}
}