refactor: extract generic workload-layer from node configs
This commit is contained in:
parent
f9e883d1b8
commit
e23006d701
7 changed files with 3 additions and 41 deletions
|
|
@ -80,7 +80,7 @@ in {
|
||||||
StateDirectory = "hypervisor-gitops";
|
StateDirectory = "hypervisor-gitops";
|
||||||
WorkingDirectory = "/var/lib/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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
# Resource Pools
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,6 @@ variable "node_name" {
|
||||||
description = "The name of the Proxmox node (e.g. pve)"
|
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" {
|
variable "zfs_pool_name" {
|
||||||
type = string
|
type = string
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ provider "proxmox" {
|
||||||
module "proxmox_node" {
|
module "proxmox_node" {
|
||||||
source = "../../modules/proxmox-node"
|
source = "../../modules/proxmox-node"
|
||||||
node_name = "mikoshi"
|
node_name = "mikoshi"
|
||||||
data_disk_id = "nvme-KXG80ZNV2T04_NVMe_KIOXIA_2048GB_241C11Y5EHAK"
|
|
||||||
zfs_pool_name = "data"
|
zfs_pool_name = "data"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# Usage: ./hypervisor-sync.sh <REPO_URL> <OPENTOFU_DIR>
|
# Usage: ./hypervisor-sync.sh <REPO_URL> <OPENTOFU_DIR>
|
||||||
|
|
||||||
REPO_URL=${1:-"https://git.depeuter.dev/Bos55/nix-config.git"}
|
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..."
|
echo "Starting Hypervisor GitOps sync..."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ fi
|
||||||
|
|
||||||
# Ensure workspace directory exists for this PR
|
# Ensure workspace directory exists for this PR
|
||||||
WORKSPACE="/var/lib/hypervisor-gitops/staging-pr-${PR_NUMBER}"
|
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 API variables
|
||||||
TRUENAS_URL=${TRUENAS_URL:-"https://192.168.0.11"}
|
TRUENAS_URL=${TRUENAS_URL:-"https://192.168.0.11"}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue