Initial: Hugo + Terraform Staging/Production Pipeline

This commit is contained in:
2026-05-06 18:02:41 +00:00
commit 3e61e70f36
12 changed files with 255 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "~> 2.9"
}
}
}
provider "proxmox" {
pm_api_url = var.proxmox_host
pm_api_token_id = var.proxmox_token_id
pm_api_token_secret = var.proxmox_token_secret
pm_tls_insecure = true
}
resource "proxmox_lxc" "staging" {
target_node = var.proxmox_node
hostname = "hugo-staging"
ostemplate = var.lxc_ostemplate
unprivileged = true
start = true
onboot = false
cores = 1
memory = 512
swap = 512
rootfs {
storage = var.lxc_storage
size = "8G"
}
network {
name = "eth0"
bridge = "vmbr0"
ip = var.staging_ip
gw = var.staging_gw != "" ? var.staging_gw : null
}
ssh_public_keys = var.ssh_public_key
provisioner "remote-exec" {
inline = [
"apt-get update -qq",
"apt-get install -y nginx",
"systemctl enable --now nginx",
"mkdir -p /var/www/html",
"chown -R www-data:www-data /var/www/html"
]
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/deploy_key")
host = self.network[0].ip
}
}
}
output "staging_ip" {
value = proxmox_lxc.staging.network[0].ip
}
+9
View File
@@ -0,0 +1,9 @@
proxmox_host = "https://192.168.1.10:8006/api2/json"
proxmox_token_id = "terraform@pve!deploy"
proxmox_token_secret = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
proxmox_node = "pve"
lxc_ostemplate = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
lxc_storage = "local-lvm"
staging_ip = "192.168.1.50/24"
staging_gw = "192.168.1.1"
ssh_public_key = "ssh-ed25519 AAAA... gitea-runner-deploy"
+50
View File
@@ -0,0 +1,50 @@
variable "proxmox_host" {
description = "Proxmox API URL"
type = string
}
variable "proxmox_token_id" {
description = "Proxmox API Token ID (user@realm!tokenid)"
type = string
}
variable "proxmox_token_secret" {
description = "Proxmox API Token Secret"
type = string
sensitive = true
}
variable "proxmox_node" {
description = "Ziel-Proxmox-Node"
type = string
default = "pve"
}
variable "lxc_ostemplate" {
description = "Pfad zum LXC-Template"
type = string
default = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
}
variable "lxc_storage" {
description = "Storage fuer LXC rootfs"
type = string
default = "local-lvm"
}
variable "staging_ip" {
description = "Statische IP fuer Staging-LXC (CIDR)"
type = string
default = "dhcp"
}
variable "staging_gw" {
description = "Gateway fuer Staging-LXC"
type = string
default = ""
}
variable "ssh_public_key" {
description = "SSH Public Key fuer den deploy-User im LXC"
type = string
}