Compare commits

...

22 Commits

Author SHA1 Message Date
sebastian.serfling 78fd15de69 .gitea/workflows/staging.yml aktualisiert 2026-05-08 13:47:55 +00:00
Sebastian Serfling 6a5b529fc8 change workflow staging
Deploy Staging / staging (push) Has been cancelled
2026-05-08 15:47:21 +02:00
Sebastian Serfling 184d8ca313 simplify: nutze ~/.ssh/deploy vom proxmox host
Deploy Staging / staging (push) Failing after 3m7s
2026-05-08 15:37:37 +02:00
Sebastian Serfling a429605f32 simplify: nutze ~/.ssh/deploy vom proxmox host
Deploy Staging / staging (push) Failing after 10s
2026-05-08 15:36:33 +02:00
Sebastian Serfling 0a4568fc83 simplify: nutze ~/.ssh/deploy vom proxmox host
Deploy Staging / staging (push) Failing after 12s
2026-05-08 15:12:54 +02:00
Sebastian Serfling 1f5abb9bc5 feat: setup jetzt via ssh-key nach pct create
Deploy Staging / staging (push) Failing after 48s
2026-05-08 15:09:29 +02:00
Sebastian Serfling 666ae202fb fix: ssh-public-keys als datei statt string
Deploy Staging / staging (push) Failing after 27s
2026-05-08 15:05:56 +02:00
Sebastian Serfling 4d155c907e debug: zeige pct create fehler
Deploy Staging / staging (push) Failing after 8s
2026-05-08 15:04:37 +02:00
Sebastian Serfling 46cd198b41 feat: ssh-public-keys direkt beim pct create
Deploy Staging / staging (push) Failing after 19s
2026-05-08 14:59:27 +02:00
Sebastian Serfling 91a96e6cd3 feat: ssh-public-keys direkt beim pct create
Deploy Staging / staging (push) Failing after 12s
2026-05-08 14:58:10 +02:00
Sebastian Serfling 63145188f8 feat: root password setup + ssh timeout fix
Deploy Staging / staging (push) Has been cancelled
2026-05-08 14:50:21 +02:00
Sebastian Serfling bda56f8563 feat: change Debain Version to 12
Deploy Staging / staging (push) Has been cancelled
2026-05-08 14:43:19 +02:00
Sebastian Serfling 0a4f1ba1e9 feat: pct destroy für sauberes Staging Redeploy
Deploy Staging / staging (push) Has been cancelled
2026-05-08 14:39:45 +02:00
Sebastian Serfling e53a6016cd feat: terraform import für alte VM - clean deploy
Deploy Staging / staging (push) Failing after 3s
2026-05-08 14:35:07 +02:00
Sebastian Serfling cc4ae05638 fix: direktes Löschen der alten VM via Proxmox API
Deploy Staging / staging (push) Failing after 12s
2026-05-08 14:33:21 +02:00
Sebastian Serfling 9d2f12a8ef fix: terraform refresh vor destroy + lifecycle rules
Deploy Staging / staging (push) Failing after 4s
2026-05-08 14:31:30 +02:00
Sebastian Serfling f58b75980b trigger: staging workflow test
Deploy Staging / staging (push) Failing after 3s
2026-05-08 14:29:44 +02:00
Sebastian Serfling 04e38a03c6 feat: Terraform Staging - destroy alte VM vor neuem Deploy
Deploy Staging / staging (push) Failing after 3s
2026-05-08 13:54:05 +02:00
sebastian.serfling 81d4126e0f terraform/variables.tf aktualisiert
Deploy Staging / staging (push) Failing after 4s
2026-05-07 17:58:00 +00:00
sebastian.serfling 64b17872a8 terraform/terraform.tfvars.example aktualisiert
Deploy Staging / staging (push) Failing after 6s
2026-05-07 17:57:01 +00:00
sebastian.serfling 3a5b252dca change lxc_storage
Deploy Staging / staging (push) Failing after 5s
2026-05-07 17:52:28 +00:00
Sebastian Serfling 623d03e559 test: trigger staging deployment workflow
Deploy Staging / staging (push) Failing after 3s
2026-05-07 15:00:25 +02:00
5 changed files with 65 additions and 50 deletions
+8 -14
View File
@@ -3,7 +3,7 @@ name: Deploy Staging
on: on:
push: push:
branches: branches:
- main - "dev*"
jobs: jobs:
staging: staging:
@@ -14,6 +14,11 @@ jobs:
with: with:
submodules: true submodules: true
- name: Delete alte Staging VM (CT 200)
run: |
pct destroy 200 --force || true
sleep 3
- name: Terraform Init & Apply (Staging LXC erstellen) - name: Terraform Init & Apply (Staging LXC erstellen)
working-directory: terraform working-directory: terraform
run: | run: |
@@ -26,24 +31,13 @@ jobs:
-var="lxc_bridge=vmbr2" \ -var="lxc_bridge=vmbr2" \
-var="staging_ip=${{ secrets.STAGING_IP }}" \ -var="staging_ip=${{ secrets.STAGING_IP }}" \
-var="staging_gw=${{ secrets.STAGING_GW }}" \ -var="staging_gw=${{ secrets.STAGING_GW }}" \
-var="ssh_public_key=${{ secrets.DEPLOY_SSH_PUBKEY }}" \ -var="root_password=${{ secrets.ROOT_PASSWORD }}"
-var="ssh_private_key=${{ secrets.DEPLOY_SSH_KEY }}"
env: env:
TF_IN_AUTOMATION: "true" TF_IN_AUTOMATION: "true"
- name: Warte auf LXC Boot
run: sleep 30
- name: SSH Key Setup
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" | base64 -d > ~/.ssh/staging_key
chmod 600 ~/.ssh/staging_key
ssh-keyscan -H ${{ secrets.STAGING_IP }} >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Hugo Clone & Build auf Staging-LXC - name: Hugo Clone & Build auf Staging-LXC
run: | run: |
ssh -i ~/.ssh/staging_key -o StrictHostKeyChecking=no deploy@${{ secrets.STAGING_IP }} bash << 'EOF' ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no root@${{ secrets.STAGING_IP }} bash << 'EOF'
set -e set -e
cd /tmp cd /tmp
+1
View File
@@ -0,0 +1 @@
Test Deploy
+32 -34
View File
@@ -14,58 +14,56 @@ provider "proxmox" {
pm_tls_insecure = true pm_tls_insecure = true
} }
resource "proxmox_lxc" "staging" { # Create staging LXC mit pct-Befehl
target_node = var.proxmox_node resource "null_resource" "staging_lxc" {
hostname = "hugo-staging" # SSH Public Key in Datei schreiben
vmid = 200 provisioner "local-exec" {
ostemplate = var.lxc_ostemplate command = "mkdir -p /tmp/terraform && echo '${var.ssh_public_key}' > /tmp/terraform/staging_key.pub"
unprivileged = true
start = true
onboot = false
cores = 2
memory = 1024
swap = 512
rootfs {
storage = var.lxc_storage
size = "10G"
} }
network { provisioner "local-exec" {
name = "eth0" command = <<-EOT
bridge = var.lxc_bridge pct create 200 \
ip = "${var.staging_ip}/24" ${var.lxc_ostemplate} \
gw = var.staging_gw --hostname hugo-staging \
--cores ${var.lxc_cores} \
--memory ${var.lxc_memory} \
--swap ${var.lxc_swap} \
--rootfs ${var.lxc_rootfs} \
--net0 name=eth0,bridge=${var.lxc_bridge},ip=${var.staging_ip}/24,gw=${var.staging_gw} \
--unprivileged 1 \
--start 1 \
--password "${var.root_password}" \
--ssh-public-keys /tmp/terraform/staging_key.pub
EOT
} }
ssh_public_keys = var.ssh_public_key provisioner "local-exec" {
command = "sleep 30"
}
# Setup via SSH (nutzt ~/.ssh/deploy vom Proxmox Host)
provisioner "remote-exec" { provisioner "remote-exec" {
inline = [ inline = [
"apt-get update -qq", "apt-get update -qq",
"apt-get install -y hugo nginx git rsync curl", "apt-get install -y hugo nginx git rsync curl",
"systemctl enable --now nginx", "systemctl enable --now nginx",
"useradd -m -s /bin/bash deploy || true", "useradd -m -s /bin/bash deploy 2>/dev/null || true",
"mkdir -p /home/deploy/.ssh",
"chmod 700 /home/deploy/.ssh",
"echo '${var.ssh_public_key}' >> /home/deploy/.ssh/authorized_keys",
"chmod 600 /home/deploy/.ssh/authorized_keys",
"chown -R deploy:deploy /home/deploy/.ssh",
"mkdir -p /var/www/html", "mkdir -p /var/www/html",
"chown -R deploy:deploy /var/www/html" "chown -R deploy:deploy /var/www/html",
"echo '✅ Staging VM Setup complete!'"
] ]
connection { connection {
type = "ssh" type = "ssh"
user = "root" user = "root"
private_key = var.ssh_private_key private_key = file(pathexpand("~/.ssh/deploy_key"))
host = self.network[0].ip host = var.staging_ip
timeout = "5m"
} }
} }
depends_on = []
} }
output "staging_ip" { output "staging_ip" {
value = proxmox_lxc.staging.network[0].ip value = "${var.staging_ip}/24"
} }
+1 -1
View File
@@ -2,7 +2,7 @@ proxmox_host = "https://192.168.1.10:8006/api2/json"
proxmox_token_id = "terraform@pve!deploy" proxmox_token_id = "terraform@pve!deploy"
proxmox_token_secret = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" proxmox_token_secret = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
proxmox_node = "pve" proxmox_node = "pve"
lxc_ostemplate = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst" lxc_ostemplate = "local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst"
lxc_storage = "local-lvm" lxc_storage = "local-lvm"
staging_ip = "192.168.1.50/24" staging_ip = "192.168.1.50/24"
staging_gw = "192.168.1.1" staging_gw = "192.168.1.1"
+23 -1
View File
@@ -27,7 +27,7 @@ variable "lxc_bridge" {
variable "lxc_ostemplate" { variable "lxc_ostemplate" {
description = "Pfad zum LXC-Template" description = "Pfad zum LXC-Template"
type = string type = string
default = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst" default = "local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"
} }
variable "lxc_storage" { variable "lxc_storage" {
@@ -58,3 +58,25 @@ variable "ssh_private_key" {
type = string type = string
sensitive = true sensitive = true
} }
variable "root_password" {
description = "Root Password für Staging VM"
type = string
sensitive = true
}
variable "lxc_cores" {
default = 2
}
variable "lxc_memory" {
default = 1024
}
variable "lxc_swap" {
default = 512
}
variable "lxc_rootfs" {
default = "SSD:10"
}