Compare commits

7 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
5 changed files with 80 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
run-name: ${{ gitea.actor }} is deploying with Terraform 🚀
on:
push:
@@ -15,6 +15,10 @@ jobs:
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
@@ -33,12 +37,11 @@ jobs:
working-directory: terraform
run: terraform init
- name: Terraform Plan
working-directory: terraform
run: terraform plan
run: terraform plan
- name: Terraform Apply
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:
push:
branches:
- stage
- test
- stage
- test
jobs:
terraform:
@@ -16,6 +16,12 @@ jobs:
contents: read
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:
- name: Checkout repository
uses: actions/checkout@v4

View File

@@ -4,13 +4,14 @@ data "template_file" "cloud_init_alpaca" {
template = file("${path.module}/files/cloud_init.yaml")
vars = {
ssh_key = file("~/.ssh/id_ed25519.pub")
hostname = "alpaca-${count.index + 1}"
domain = "home.arpa"
tailscale_key = var.tailscale_key
ssh_key = var.ssh_key
hostname = "alpaca-${count.index + 1}"
domain = "home.arpa"
TS_AUTHKEY = var.TS_AUTHKEY
}
}
resource "local_file" "cloud_init_alpaca" {
count = var.alpaca_vm_count
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
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/id_ed25519")
host = var.target_node
type = "ssh"
user = "root"
host = var.target_node
}
provisioner "file" {
@@ -39,13 +39,14 @@ data "template_file" "cloud_init_llama" {
template = file("${path.module}/files/cloud_init.yaml")
vars = {
ssh_key = file("~/.ssh/id_ed25519.pub")
hostname = "llama-${count.index + 1}"
domain = "home.arpa"
tailscale_key = var.tailscale_key
ssh_key = var.ssh_key
hostname = "llama-${count.index + 1}"
domain = "home.arpa"
TS_AUTHKEY = var.TS_AUTHKEY
}
}
resource "local_file" "cloud_init_llama" {
count = var.llama_vm_count
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
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/id_ed25519")
host = var.target_node
type = "ssh"
user = "root"
host = var.target_node
}
provisioner "file" {

View File

@@ -74,8 +74,14 @@ variable "llama_vm_count" {
description = "How many Llama VMs to create"
}
variable "tailscale_key" {
variable "TS_AUTHKEY" {
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"
}