refactor: extract generic workload-layer from node configs

This commit is contained in:
Tibo De Peuter 2026-08-18 20:13:25 +02:00
parent f9e883d1b8
commit e23006d701
7 changed files with 3 additions and 41 deletions

View file

@ -80,7 +80,7 @@ in {
StateDirectory = "hypervisor-gitops";
WorkingDirectory = "/var/lib/hypervisor-gitops";
ExecStart = "${hypervisorSyncScript}/bin/hypervisor-sync ${cfg.repoUrl} opentofu/nodes/mikoshi";
ExecStart = "${hypervisorSyncScript}/bin/hypervisor-sync ${cfg.repoUrl} opentofu/workload-layer/production";
};
};

View file

@ -7,40 +7,7 @@ terraform {
}
}
# Bare Metal Host Configurations (SSH Provisioning)
# We use a null_resource to run imperative commands on the Debian host
# that are not currently supported by the bpg/proxmox provider.
resource "null_resource" "bare_metal_setup" {
triggers = {
node = var.node_name
data_disk_id = var.data_disk_id
pool_name = var.zfs_pool_name
}
connection {
type = "ssh"
user = "root"
# Assuming running locally on the node during bootstrap, or via SSH if run from a laptop.
# We default to local host if run from Control Center, but for flexibility we use the endpoint.
host = var.node_name
agent = true
}
provisioner "remote-exec" {
inline = [
# Set laptop lid switch to ignore (prevents sleeping when closed)
"sed -i 's/^#\\?HandleLidSwitch=.*/HandleLidSwitch=ignore/' /etc/systemd/logind.conf",
"systemctl restart systemd-logind",
# Format the ZFS pool if it doesn't already exist
"zpool list ${var.zfs_pool_name} || zpool create -f ${var.zfs_pool_name} /dev/disk/by-id/${var.data_disk_id}",
# Register the ZFS pool in Proxmox if it's not already registered
"pvesm status -storage ${var.zfs_pool_name} || pvesm add zfspool ${var.zfs_pool_name} --pool ${var.zfs_pool_name} --content images,rootdir"
]
}
}
# Resource Pools

View file

@ -3,10 +3,6 @@ variable "node_name" {
description = "The name of the Proxmox node (e.g. pve)"
}
variable "data_disk_id" {
type = string
description = "The persistent block device ID for the data disk (e.g. wwn-0x500...)"
}
variable "zfs_pool_name" {
type = string

View file

@ -19,7 +19,6 @@ provider "proxmox" {
module "proxmox_node" {
source = "../../modules/proxmox-node"
node_name = "mikoshi"
data_disk_id = "nvme-KXG80ZNV2T04_NVMe_KIOXIA_2048GB_241C11Y5EHAK"
zfs_pool_name = "data"
}

View file

@ -5,7 +5,7 @@
# Usage: ./hypervisor-sync.sh <REPO_URL> <OPENTOFU_DIR>
REPO_URL=${1:-"https://git.depeuter.dev/Bos55/nix-config.git"}
OPENTOFU_DIR=${2:-"opentofu/nodes/mikoshi"}
OPENTOFU_DIR=${2:-"opentofu/workload-layer/production"}
echo "Starting Hypervisor GitOps sync..."

View file

@ -26,7 +26,7 @@ fi
# Ensure workspace directory exists for this PR
WORKSPACE="/var/lib/hypervisor-gitops/staging-pr-${PR_NUMBER}"
OPENTOFU_SRC="/var/lib/hypervisor-gitops/nix-config/opentofu/staging-env"
OPENTOFU_SRC="/var/lib/hypervisor-gitops/nix-config/opentofu/workload-layer/staging"
# TrueNAS API variables
TRUENAS_URL=${TRUENAS_URL:-"https://192.168.0.11"}