fix(ci): Configure CI/CD workflow triggers
Some checks failed
CD - Deploy Infrastructure / Terraform Validation (push) Successful in 16s
CD - Deploy Infrastructure / Deploy on pve1 (push) Failing after 1m5s
CD - Deploy Infrastructure / Deploy on pve2 (push) Failing after 2m25s
CD - Deploy Infrastructure / Deploy on pve3 (push) Failing after 2m12s
CD - Deploy Infrastructure / Validate K3s Cluster (push) Has been skipped
CD - Deploy Infrastructure / Deployment Notification (push) Failing after 1s

This commit is contained in:
Tellsanguis 2025-11-26 19:28:17 +01:00
parent 801e130679
commit c70d3e3c03
8 changed files with 181 additions and 74 deletions

View file

@ -6,6 +6,7 @@ on:
- '**' - '**'
- '!main' # Exclude main branch (CD workflow handles it) - '!main' # Exclude main branch (CD workflow handles it)
pull_request: pull_request:
workflow_call: # Allow this workflow to be called by other workflows
jobs: jobs:
ci-terraform: ci-terraform:

View file

@ -7,20 +7,80 @@ on:
workflow_dispatch: # Allow manual trigger workflow_dispatch: # Allow manual trigger
jobs: jobs:
# Run CI first # Run Terraform validation first
ci: ci-terraform:
uses: ./.forgejo/workflows/ci.yml name: Terraform Validation
secrets: inherit runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup OpenTofu
run: |
if ! command -v tofu &> /dev/null; then
curl -fsSL https://get.opentofu.org/install-opentofu.sh | bash -s -- --install-method standalone --opentofu-version 1.10.7
fi
- name: Terraform Format Check
run: |
cd terraform
tofu fmt -check -recursive
continue-on-error: false
- name: Terraform Validate
run: |
for dir in terraform/pve*; do
if [ -d "$dir" ]; then
echo "--- Validating $dir ---"
(cd "$dir" && tofu init -backend=false && tofu validate)
fi
done
- name: Terraform Plan
run: |
for dir in terraform/pve*; do
if [ -d "$dir" ]; then
echo "--- Planning $dir ---"
(
cd "$dir" && \
tofu init && \
tofu plan || echo "WARNING: Plan failed for $(basename $dir) - node may be unavailable"
)
fi
done
env:
TF_VAR_proxmox_api_url: "https://192.168.100.10:8006/api2/json"
TF_VAR_proxmox_token_id: ${{ secrets.PROXMOX_TOKEN_ID }}
TF_VAR_proxmox_token_secret: ${{ secrets.PROXMOX_TOKEN_SECRET }}
TF_VAR_proxmox_tls_insecure: "true"
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
TF_VAR_forgejo_token: ${{ secrets.GIT_TOKEN }}
TF_VAR_forgejo_repo_url: ${{ secrets.GIT_REPO_URL }}
TF_VAR_k3s_version: "v1.28.5+k3s1"
TF_VAR_ubuntu_template: "ubuntu-2404-cloudinit"
TF_VAR_storage_pool: "linstor_storage"
TF_VAR_snippets_storage: "local"
TF_VAR_k3s_network_bridge: "k3s"
TF_VAR_k3s_gateway: "10.100.20.1"
TF_VAR_k3s_dns: '["10.100.20.1", "1.1.1.1"]'
TF_VAR_k3s_server_1_config: '{ ip = "10.100.20.10/24", cores = 6, memory = 12288, disk_size = "100G" }'
TF_VAR_k3s_server_2_config: '{ ip = "10.100.20.20/24", cores = 6, memory = 12288, disk_size = "100G" }'
TF_VAR_etcd_witness_config: '{ ip = "10.100.20.30/24", cores = 2, memory = 2048, disk_size = "20G" }'
# Deploy infrastructure in parallel # Deploy infrastructure in parallel
deploy-pve1: deploy-pve1:
name: Deploy on pve1 name: Deploy on pve1
runs-on: self-hosted runs-on: self-hosted
needs: ci needs: ci-terraform
continue-on-error: true continue-on-error: true
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup OpenTofu
run: |
if ! command -v tofu &> /dev/null; then
curl -fsSL https://get.opentofu.org/install-opentofu.sh | bash -s -- --install-method standalone --opentofu-version 1.10.7
fi
- name: Terraform Apply on pve1 - name: Terraform Apply on pve1
run: | run: |
cd terraform/pve1 cd terraform/pve1
@ -33,6 +93,7 @@ jobs:
k3s_version = "v1.28.5+k3s1" k3s_version = "v1.28.5+k3s1"
ubuntu_template = "ubuntu-2404-cloudinit" ubuntu_template = "ubuntu-2404-cloudinit"
storage_pool = "linstor_storage" storage_pool = "linstor_storage"
k3s_server_1_storage_pool = "linstor_storage"
snippets_storage = "local" snippets_storage = "local"
k3s_network_bridge = "k3s" k3s_network_bridge = "k3s"
k3s_gateway = "10.100.20.1" k3s_gateway = "10.100.20.1"
@ -45,11 +106,16 @@ jobs:
deploy-pve2: deploy-pve2:
name: Deploy on pve2 name: Deploy on pve2
runs-on: self-hosted runs-on: self-hosted
needs: ci needs: ci-terraform
continue-on-error: true continue-on-error: true
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup OpenTofu
run: |
if ! command -v tofu &> /dev/null; then
curl -fsSL https://get.opentofu.org/install-opentofu.sh | bash -s -- --install-method standalone --opentofu-version 1.10.7
fi
- name: Terraform Apply on pve2 - name: Terraform Apply on pve2
run: | run: |
cd terraform/pve2 cd terraform/pve2
@ -62,6 +128,7 @@ jobs:
k3s_version = "v1.28.5+k3s1" k3s_version = "v1.28.5+k3s1"
ubuntu_template = "ubuntu-2404-cloudinit" ubuntu_template = "ubuntu-2404-cloudinit"
storage_pool = "linstor_storage" storage_pool = "linstor_storage"
k3s_server_2_storage_pool = "linstor_storage"
snippets_storage = "local" snippets_storage = "local"
k3s_network_bridge = "k3s" k3s_network_bridge = "k3s"
k3s_gateway = "10.100.20.1" k3s_gateway = "10.100.20.1"
@ -74,11 +141,16 @@ jobs:
deploy-pve3: deploy-pve3:
name: Deploy on pve3 name: Deploy on pve3
runs-on: self-hosted runs-on: self-hosted
needs: ci needs: ci-terraform
continue-on-error: true continue-on-error: true
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup OpenTofu
run: |
if ! command -v tofu &> /dev/null; then
curl -fsSL https://get.opentofu.org/install-opentofu.sh | bash -s -- --install-method standalone --opentofu-version 1.10.7
fi
- name: Terraform Apply on pve3 - name: Terraform Apply on pve3
run: | run: |
cd terraform/pve3 cd terraform/pve3
@ -91,6 +163,7 @@ jobs:
k3s_version = "v1.28.5+k3s1" k3s_version = "v1.28.5+k3s1"
ubuntu_template = "ubuntu-2404-cloudinit" ubuntu_template = "ubuntu-2404-cloudinit"
storage_pool = "linstor_storage" storage_pool = "linstor_storage"
etcd_witness_storage_pool = "local-lvm"
snippets_storage = "local" snippets_storage = "local"
k3s_network_bridge = "k3s" k3s_network_bridge = "k3s"
k3s_gateway = "10.100.20.1" k3s_gateway = "10.100.20.1"

View file

@ -4,7 +4,7 @@ terraform {
required_providers { required_providers {
proxmox = { proxmox = {
source = "telmate/proxmox" source = "telmate/proxmox"
version = "~> 2.9" version = "3.0.2-rc05"
} }
local = { local = {
source = "hashicorp/local" source = "hashicorp/local"
@ -20,14 +20,18 @@ provider "proxmox" {
pm_tls_insecure = var.proxmox_tls_insecure pm_tls_insecure = var.proxmox_tls_insecure
} }
# K3s Server VM on pve1 # K3s Server VM on acemagician
resource "proxmox_vm_qemu" "k3s_server_1" { resource "proxmox_vm_qemu" "k3s_server_1" {
name = "k3s-server-1" name = "k3s-server-1"
target_node = "pve1" target_node = "acemagician"
clone = var.ubuntu_template clone = var.ubuntu_template
full_clone = true
cpu {
cores = var.k3s_server_1_config.cores cores = var.k3s_server_1_config.cores
sockets = 1 sockets = 1
}
memory = var.k3s_server_1_config.memory memory = var.k3s_server_1_config.memory
agent = 1 agent = 1
@ -36,16 +40,17 @@ resource "proxmox_vm_qemu" "k3s_server_1" {
onboot = true onboot = true
network { network {
id = 0
model = "virtio" model = "virtio"
bridge = var.k3s_network_bridge bridge = var.k3s_network_bridge
} }
disk { disk {
slot = 0 slot = "scsi0"
size = var.k3s_server_1_config.disk_size size = var.k3s_server_1_config.disk_size
type = "scsi" type = "disk"
storage = var.storage_pool storage = var.k3s_server_1_storage_pool
iothread = 1 iothread = true
} }
ipconfig0 = "ip=${var.k3s_server_1_config.ip},gw=${var.k3s_gateway}" ipconfig0 = "ip=${var.k3s_server_1_config.ip},gw=${var.k3s_gateway}"

View file

@ -53,6 +53,12 @@ variable "storage_pool" {
type = string type = string
} }
variable "k3s_server_1_storage_pool" {
description = "Storage pool for k3s-server-1 disk (linstor_storage for HA)"
type = string
default = "linstor_storage"
}
variable "snippets_storage" { variable "snippets_storage" {
description = "Proxmox storage for cloud-init snippets" description = "Proxmox storage for cloud-init snippets"
type = string type = string

View file

@ -4,7 +4,7 @@ terraform {
required_providers { required_providers {
proxmox = { proxmox = {
source = "telmate/proxmox" source = "telmate/proxmox"
version = "~> 2.9" version = "3.0.2-rc05"
} }
local = { local = {
source = "hashicorp/local" source = "hashicorp/local"
@ -20,14 +20,18 @@ provider "proxmox" {
pm_tls_insecure = var.proxmox_tls_insecure pm_tls_insecure = var.proxmox_tls_insecure
} }
# K3s Server VM on pve2 # K3s Server VM on elitedesk
resource "proxmox_vm_qemu" "k3s_server_2" { resource "proxmox_vm_qemu" "k3s_server_2" {
name = "k3s-server-2" name = "k3s-server-2"
target_node = "pve2" target_node = "elitedesk"
clone = var.ubuntu_template clone = var.ubuntu_template
full_clone = true
cpu {
cores = var.k3s_server_2_config.cores cores = var.k3s_server_2_config.cores
sockets = 1 sockets = 1
}
memory = var.k3s_server_2_config.memory memory = var.k3s_server_2_config.memory
agent = 1 agent = 1
@ -36,16 +40,17 @@ resource "proxmox_vm_qemu" "k3s_server_2" {
onboot = true onboot = true
network { network {
id = 0
model = "virtio" model = "virtio"
bridge = var.k3s_network_bridge bridge = var.k3s_network_bridge
} }
disk { disk {
slot = 0 slot = "scsi0"
size = var.k3s_server_2_config.disk_size size = var.k3s_server_2_config.disk_size
type = "scsi" type = "disk"
storage = var.storage_pool storage = var.k3s_server_2_storage_pool
iothread = 1 iothread = true
} }
ipconfig0 = "ip=${var.k3s_server_2_config.ip},gw=${var.k3s_gateway}" ipconfig0 = "ip=${var.k3s_server_2_config.ip},gw=${var.k3s_gateway}"

View file

@ -53,6 +53,12 @@ variable "storage_pool" {
type = string type = string
} }
variable "k3s_server_2_storage_pool" {
description = "Storage pool for k3s-server-2 disk (linstor_storage for HA)"
type = string
default = "linstor_storage"
}
variable "snippets_storage" { variable "snippets_storage" {
description = "Proxmox storage for cloud-init snippets" description = "Proxmox storage for cloud-init snippets"
type = string type = string

View file

@ -4,7 +4,7 @@ terraform {
required_providers { required_providers {
proxmox = { proxmox = {
source = "telmate/proxmox" source = "telmate/proxmox"
version = "~> 2.9" version = "3.0.2-rc05"
} }
local = { local = {
source = "hashicorp/local" source = "hashicorp/local"
@ -20,14 +20,18 @@ provider "proxmox" {
pm_tls_insecure = var.proxmox_tls_insecure pm_tls_insecure = var.proxmox_tls_insecure
} }
# etcd Witness VM on pve3 # etcd Witness VM on thinkpad
resource "proxmox_vm_qemu" "etcd_witness" { resource "proxmox_vm_qemu" "etcd_witness" {
name = "etcd-witness" name = "etcd-witness"
target_node = "pve3" target_node = "thinkpad"
clone = var.ubuntu_template clone = var.ubuntu_template
full_clone = true
cpu {
cores = var.etcd_witness_config.cores cores = var.etcd_witness_config.cores
sockets = 1 sockets = 1
}
memory = var.etcd_witness_config.memory memory = var.etcd_witness_config.memory
agent = 1 agent = 1
@ -36,16 +40,17 @@ resource "proxmox_vm_qemu" "etcd_witness" {
onboot = true onboot = true
network { network {
id = 0
model = "virtio" model = "virtio"
bridge = var.k3s_network_bridge bridge = var.k3s_network_bridge
} }
disk { disk {
slot = 0 slot = "scsi0"
size = var.etcd_witness_config.disk_size size = var.etcd_witness_config.disk_size
type = "scsi" type = "disk"
storage = var.storage_pool storage = var.etcd_witness_storage_pool
iothread = 1 iothread = true
} }
ipconfig0 = "ip=${var.etcd_witness_config.ip},gw=${var.k3s_gateway}" ipconfig0 = "ip=${var.etcd_witness_config.ip},gw=${var.k3s_gateway}"

View file

@ -53,6 +53,12 @@ variable "storage_pool" {
type = string type = string
} }
variable "etcd_witness_storage_pool" {
description = "Proxmox storage pool for etcd witness VM disk (thinkpad uses local storage)"
type = string
default = "local-lvm"
}
variable "snippets_storage" { variable "snippets_storage" {
description = "Proxmox storage for cloud-init snippets" description = "Proxmox storage for cloud-init snippets"
type = string type = string