Compare commits
8 Commits
72f0080660
...
destroy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f90075f098 | ||
|
|
5a0f927532 | ||
|
|
e968321c39 | ||
|
|
feb21cadfa | ||
|
|
36cba568f2 | ||
|
|
c1c533f92d | ||
|
|
2b8233e870 | ||
|
|
c430a206c3 |
@@ -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,7 +37,6 @@ 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
|
||||||
|
|||||||
43
.gitea/workflows/terraform-destroy.yml
Normal file
43
.gitea/workflows/terraform-destroy.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Gitea Destroy Terraform
|
||||||
|
run-name: ${{ gitea.actor }} triggered a Terraform Destroy 🧨
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- destroy
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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" {
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user