Compare commits
1 Commits
d634e124a3
...
destroy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f90075f098 |
@@ -16,7 +16,6 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ name: Gitea Destroy Terraform
|
||||
run-name: ${{ gitea.actor }} triggered a Terraform Destroy 🧨
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Manual trigger
|
||||
push:
|
||||
branches:
|
||||
- destroy
|
||||
|
||||
jobs:
|
||||
destroy:
|
||||
@@ -14,11 +16,9 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -17,9 +17,10 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
TF_VAR_TAILSCALE_KEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
# TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
||||
@@ -1,17 +1,70 @@
|
||||
### Global cloud-init template (for all VMs)
|
||||
|
||||
data "template_file" "cloud_init_global" {
|
||||
template = file("${path.module}/files/cloud_init_global.yaml")
|
||||
### Alpaca cloud-init template
|
||||
data "template_file" "cloud_init_alpaca" {
|
||||
count = var.alpaca_vm_count
|
||||
template = file("${path.module}/files/cloud_init.yaml")
|
||||
|
||||
vars = {
|
||||
hostname = "generic"
|
||||
ssh_key = var.ssh_key
|
||||
hostname = "alpaca-${count.index + 1}"
|
||||
domain = "home.arpa"
|
||||
TS_AUTHKEY = var.TS_AUTHKEY
|
||||
}
|
||||
}
|
||||
|
||||
resource "local_file" "cloud_init_global" {
|
||||
content = data.template_file.cloud_init_global.rendered
|
||||
filename = "${path.module}/files/cloud_init_global.yaml"
|
||||
|
||||
resource "local_file" "cloud_init_alpaca" {
|
||||
count = var.alpaca_vm_count
|
||||
content = data.template_file.cloud_init_alpaca[count.index].rendered
|
||||
filename = "${path.module}/files/cloud_init_alpaca_${count.index + 1}.yaml"
|
||||
}
|
||||
|
||||
resource "null_resource" "upload_cloud_init_alpaca" {
|
||||
count = var.alpaca_vm_count
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
user = "root"
|
||||
host = var.target_node
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = local_file.cloud_init_alpaca[count.index].filename
|
||||
destination = "/var/lib/vz/snippets/cloud_init_alpaca_${count.index + 1}.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
### Llama cloud-init template
|
||||
data "template_file" "cloud_init_llama" {
|
||||
count = var.llama_vm_count
|
||||
template = file("${path.module}/files/cloud_init.yaml")
|
||||
|
||||
vars = {
|
||||
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
|
||||
filename = "${path.module}/files/cloud_init_llama_${count.index + 1}.yaml"
|
||||
}
|
||||
|
||||
resource "null_resource" "upload_cloud_init_llama" {
|
||||
count = var.llama_vm_count
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
user = "root"
|
||||
host = var.target_node
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = local_file.cloud_init_llama[count.index].filename
|
||||
destination = "/var/lib/vz/snippets/cloud_init_llama_${count.index + 1}.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#cloud-config
|
||||
hostname: ${hostname}
|
||||
fqdn: ${hostname}.${domain}
|
||||
ssh_authorized_keys:
|
||||
- ${ssh_key}
|
||||
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --auth-key=${TS_AUTHKEY}
|
||||
- tailscale set --ssh
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --auth-key=${TS_AUTHKEY}
|
||||
- tailscale set --ssh
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#cloud-config
|
||||
hostname: ${hostname}
|
||||
fqdn: ${hostname}.${domain}
|
||||
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --auth-key=${TS_AUTHKEY}
|
||||
- tailscale set --ssh
|
||||
|
||||
@@ -20,7 +20,7 @@ resource "proxmox_vm_qemu" "alpacas" {
|
||||
vmid = 500 + count.index + 1
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
full_clone = true
|
||||
full_clone = false
|
||||
agent = 1
|
||||
|
||||
sockets = var.sockets
|
||||
@@ -29,24 +29,14 @@ resource "proxmox_vm_qemu" "alpacas" {
|
||||
scsihw = "virtio-scsi-pci"
|
||||
boot = "order=scsi0"
|
||||
ipconfig0 = "ip=dhcp"
|
||||
cicustom = "user=local:snippets/cloud_init_global.yaml"
|
||||
cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml"
|
||||
depends_on = [null_resource.upload_cloud_init_alpaca]
|
||||
|
||||
|
||||
disks {
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
storage = var.storage
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
iothread = true
|
||||
}
|
||||
}
|
||||
scsi1 {
|
||||
cloudinit {
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network {
|
||||
@@ -63,7 +53,7 @@ resource "proxmox_vm_qemu" "llamas" {
|
||||
vmid = 600 + count.index + 1
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
full_clone = true
|
||||
full_clone = false
|
||||
agent = 1
|
||||
|
||||
sockets = var.sockets
|
||||
@@ -72,23 +62,14 @@ resource "proxmox_vm_qemu" "llamas" {
|
||||
scsihw = "virtio-scsi-pci"
|
||||
boot = "order=scsi0"
|
||||
ipconfig0 = "ip=dhcp"
|
||||
cicustom = "user=local:snippets/cloud_init_global.yaml"
|
||||
cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml"
|
||||
depends_on = [null_resource.upload_cloud_init_llama]
|
||||
|
||||
disks {
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
storage = var.storage
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
iothread = true
|
||||
}
|
||||
}
|
||||
scsi1 {
|
||||
cloudinit {
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.8.3",
|
||||
"terraform_version": "1.11.4",
|
||||
"serial": 31,
|
||||
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
|
||||
"outputs": {},
|
||||
|
||||
@@ -79,3 +79,9 @@ variable "TS_AUTHKEY" {
|
||||
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