Compare commits

8 Commits

Author SHA1 Message Date
MichaelFisher1997
5a0f927532 terraform fmt
All checks were successful
Gitea Actions Demo / Terraform Plan (push) Successful in 25s
2025-04-17 17:08:31 +01:00
MichaelFisher1997
e968321c39 terraform fmt
All checks were successful
Gitea Actions Demo / Terraform Plan (push) Successful in 40s
2025-04-17 17:06:33 +01:00
MichaelFisher1997
feb21cadfa terraform fmt
All checks were successful
Gitea Actions Demo / Terraform Plan (push) Successful in 24s
2025-04-17 17:04:06 +01:00
MichaelFisher1997
36cba568f2 terraform fmt
Some checks failed
Gitea Actions Demo / Terraform Plan (push) Failing after 19s
2025-04-17 17:02:46 +01:00
MichaelFisher1997
c1c533f92d terraform fmt
Some checks failed
Gitea Actions Demo / Terraform Plan (push) Failing after 24s
2025-04-17 16:58:28 +01:00
MichaelFisher1997
2b8233e870 terraform fmt
Some checks failed
Gitea Actions Demo / Terraform Plan (push) Has been cancelled
2025-04-17 16:54:35 +01:00
MichaelFisher1997
c430a206c3 terraform fmt 2025-04-17 16:54:21 +01:00
MichaelFisher1997
72f0080660 terraform fmt
Some checks failed
Gitea Actions Demo / Terraform Plan (push) Failing after 20s
2025-04-17 16:48:08 +01:00
6 changed files with 96 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
name: Gitea Actions Demo name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 run-name: ${{ gitea.actor }} is deploying with Terraform 🚀
on: on:
push: push:
@@ -15,6 +15,10 @@ jobs:
contents: read contents: read
pull-requests: write pull-requests: write
env:
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -33,12 +37,11 @@ jobs:
working-directory: terraform working-directory: terraform
run: terraform init run: terraform init
- name: Terraform Plan - name: Terraform Plan
working-directory: terraform working-directory: terraform
run: terraform plan run: terraform plan
- name: Terraform Apply - name: Terraform Apply
working-directory: terraform working-directory: terraform
run: terraform apply -auto-approve run: terraform apply -auto-approve

View File

@@ -0,0 +1,41 @@
name: Gitea Destroy Terraform
run-name: ${{ gitea.actor }} triggered a Terraform Destroy 🧨
on:
workflow_dispatch: # Manual trigger
jobs:
destroy:
name: "Terraform Destroy"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.6.6
- name: Inject sensitive secrets
working-directory: terraform
run: |
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
- name: Terraform Init
working-directory: terraform
run: terraform init
- name: Terraform Destroy
working-directory: terraform
run: terraform destroy -auto-approve

View File

@@ -4,8 +4,8 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: on:
push: push:
branches: branches:
- stage - stage
- test - test
jobs: jobs:
terraform: terraform:
@@ -16,6 +16,12 @@ jobs:
contents: read contents: read
pull-requests: write pull-requests: write
env:
TF_VAR_TAILSCALE_KEY: ${{ secrets.TAILSCALE_KEY }}
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@@ -4,13 +4,14 @@ data "template_file" "cloud_init_alpaca" {
template = file("${path.module}/files/cloud_init.yaml") template = file("${path.module}/files/cloud_init.yaml")
vars = { vars = {
ssh_key = file("~/.ssh/id_ed25519.pub") ssh_key = var.ssh_key
hostname = "alpaca-${count.index + 1}" hostname = "alpaca-${count.index + 1}"
domain = "home.arpa" domain = "home.arpa"
tailscale_key = var.tailscale_key TS_AUTHKEY = var.TS_AUTHKEY
} }
} }
resource "local_file" "cloud_init_alpaca" { resource "local_file" "cloud_init_alpaca" {
count = var.alpaca_vm_count count = var.alpaca_vm_count
content = data.template_file.cloud_init_alpaca[count.index].rendered content = data.template_file.cloud_init_alpaca[count.index].rendered
@@ -21,10 +22,9 @@ resource "null_resource" "upload_cloud_init_alpaca" {
count = var.alpaca_vm_count count = var.alpaca_vm_count
connection { connection {
type = "ssh" type = "ssh"
user = "root" user = "root"
private_key = file("~/.ssh/id_ed25519") host = var.target_node
host = var.target_node
} }
provisioner "file" { provisioner "file" {
@@ -39,13 +39,14 @@ data "template_file" "cloud_init_llama" {
template = file("${path.module}/files/cloud_init.yaml") template = file("${path.module}/files/cloud_init.yaml")
vars = { vars = {
ssh_key = file("~/.ssh/id_ed25519.pub") ssh_key = var.ssh_key
hostname = "llama-${count.index + 1}" hostname = "llama-${count.index + 1}"
domain = "home.arpa" domain = "home.arpa"
tailscale_key = var.tailscale_key TS_AUTHKEY = var.TS_AUTHKEY
} }
} }
resource "local_file" "cloud_init_llama" { resource "local_file" "cloud_init_llama" {
count = var.llama_vm_count count = var.llama_vm_count
content = data.template_file.cloud_init_llama[count.index].rendered content = data.template_file.cloud_init_llama[count.index].rendered
@@ -56,10 +57,9 @@ resource "null_resource" "upload_cloud_init_llama" {
count = var.llama_vm_count count = var.llama_vm_count
connection { connection {
type = "ssh" type = "ssh"
user = "root" user = "root"
private_key = file("~/.ssh/id_ed25519") host = var.target_node
host = var.target_node
} }
provisioner "file" { provisioner "file" {

View File

@@ -23,14 +23,14 @@ resource "proxmox_vm_qemu" "alpacas" {
full_clone = false full_clone = false
agent = 1 agent = 1
sockets = var.sockets sockets = var.sockets
cores = var.cores cores = var.cores
memory = var.memory memory = var.memory
scsihw = "virtio-scsi-pci" scsihw = "virtio-scsi-pci"
boot = "order=scsi0" boot = "order=scsi0"
ipconfig0 = "ip=dhcp" ipconfig0 = "ip=dhcp"
cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml" cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml"
depends_on = [null_resource.upload_cloud_init_alpaca] depends_on = [null_resource.upload_cloud_init_alpaca]
disk { disk {
slot = "scsi0" slot = "scsi0"
@@ -56,14 +56,14 @@ resource "proxmox_vm_qemu" "llamas" {
full_clone = false full_clone = false
agent = 1 agent = 1
sockets = var.sockets sockets = var.sockets
cores = var.cores cores = var.cores
memory = var.memory memory = var.memory
scsihw = "virtio-scsi-pci" scsihw = "virtio-scsi-pci"
boot = "order=scsi0" boot = "order=scsi0"
ipconfig0 = "ip=dhcp" ipconfig0 = "ip=dhcp"
cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml" cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml"
depends_on = [null_resource.upload_cloud_init_llama] depends_on = [null_resource.upload_cloud_init_llama]
disk { disk {
slot = "scsi0" slot = "scsi0"

View File

@@ -74,8 +74,14 @@ variable "llama_vm_count" {
description = "How many Llama VMs to create" description = "How many Llama VMs to create"
} }
variable "tailscale_key" { variable "TS_AUTHKEY" {
type = string type = string
description = "Tailscale auth key" description = "Tailscale auth key used in cloud-init"
}
variable "ssh_key" {
type = string
description = "Public SSH key used by cloud-init"
} }