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
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user