Compare commits
1 Commits
ba3fe8e7ff
...
destroy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f90075f098 |
@@ -16,8 +16,8 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TF_VAR_SSH_KEY_PUBLIC: ${{ secrets.SSH_KEY_PUBLIC }}
|
|
||||||
TF_VAR_TS_AUTHKEY: ${{ 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
|
||||||
@@ -32,7 +32,6 @@ jobs:
|
|||||||
working-directory: terraform
|
working-directory: terraform
|
||||||
run: |
|
run: |
|
||||||
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
|
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
|
||||||
echo 'SSH_KEY_PUBLIC = "${{ secrets.SSH_KEY_PUBLIC }}"' >> terraform.tfvars
|
|
||||||
|
|
||||||
- name: Terraform Init
|
- name: Terraform Init
|
||||||
working-directory: terraform
|
working-directory: terraform
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ name: Gitea Destroy Terraform
|
|||||||
run-name: ${{ gitea.actor }} triggered a Terraform Destroy 🧨
|
run-name: ${{ gitea.actor }} triggered a Terraform Destroy 🧨
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: # Manual trigger
|
push:
|
||||||
|
branches:
|
||||||
|
- destroy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
destroy:
|
destroy:
|
||||||
@@ -14,10 +16,8 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
TF_VAR_TS_AUTHKEY: ${{ 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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY_PUBLIC }}
|
TF_VAR_TAILSCALE_KEY: ${{ secrets.TAILSCALE_KEY }}
|
||||||
TF_VAR_TS_AUTHKEY: ${{ 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
|
||||||
@@ -33,7 +35,6 @@ jobs:
|
|||||||
working-directory: terraform
|
working-directory: terraform
|
||||||
run: |
|
run: |
|
||||||
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
|
echo 'proxmox_password = "${{ secrets.PROXMOX_PASSWORD }}"' >> terraform.tfvars
|
||||||
echo 'SSH_KEY_PUBLIC = "${{ secrets.SSH_KEY_PUBLIC }}"' >> terraform.tfvars
|
|
||||||
|
|
||||||
- name: Terraform Init
|
- name: Terraform Init
|
||||||
working-directory: terraform
|
working-directory: terraform
|
||||||
|
|||||||
@@ -1,32 +1,70 @@
|
|||||||
### Global cloud-init template (for all VMs)
|
### Alpaca cloud-init template
|
||||||
|
data "template_file" "cloud_init_alpaca" {
|
||||||
data "template_file" "cloud_init_global" {
|
count = var.alpaca_vm_count
|
||||||
template = file("${path.module}/files/cloud_init_global.yaml")
|
template = file("${path.module}/files/cloud_init.yaml")
|
||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
hostname = "generic"
|
ssh_key = var.ssh_key
|
||||||
|
hostname = "alpaca-${count.index + 1}"
|
||||||
domain = "home.arpa"
|
domain = "home.arpa"
|
||||||
TS_AUTHKEY = var.TS_AUTHKEY
|
TS_AUTHKEY = var.TS_AUTHKEY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "local_file" "cloud_init_global" {
|
|
||||||
content = data.template_file.cloud_init_global.rendered
|
resource "local_file" "cloud_init_alpaca" {
|
||||||
filename = "${path.module}/files/cloud_init_global.yaml"
|
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#resource "null_resource" "upload_cloud_init_alpaca" {
|
|
||||||
# count = var.alpaca_vm_count
|
|
||||||
#
|
|
||||||
# connection {
|
|
||||||
# type = "ssh"
|
|
||||||
# user = "root"
|
|
||||||
# private_key = var.ssh_key
|
|
||||||
# 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"
|
|
||||||
# }
|
|
||||||
#}
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#cloud-config
|
#cloud-config
|
||||||
hostname: ${hostname}
|
hostname: ${hostname}
|
||||||
fqdn: ${hostname}.${domain}
|
fqdn: ${hostname}.${domain}
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||||
- tailscale up --auth-key=${TS_AUTHKEY}
|
- 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,43 +0,0 @@
|
|||||||
#cloud-config
|
|
||||||
|
|
||||||
package_update: true
|
|
||||||
package_upgrade: true
|
|
||||||
|
|
||||||
# APT fails to acquire GPG keys if package dirmngr is missing
|
|
||||||
bootcmd:
|
|
||||||
- [ cloud-init-per, once, dirmngr-aptupdate, apt-get, update ]
|
|
||||||
- [ cloud-init-per, once, dirmngr-aptinstall, apt-get, install, dirmngr, -y ]
|
|
||||||
- [ cloud-init-per, once, dirmngr-aptinstall, apt-get, install, gnupg2, -y ]
|
|
||||||
|
|
||||||
packages:
|
|
||||||
- jq
|
|
||||||
- curl
|
|
||||||
- qemu-guest-agent
|
|
||||||
- salt-minion
|
|
||||||
|
|
||||||
users:
|
|
||||||
- name: stuart
|
|
||||||
groups: sudo
|
|
||||||
shell: /bin/bash
|
|
||||||
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
|
||||||
ssh_authorized_keys:
|
|
||||||
- ${SSH_KEY_PUBLIC}
|
|
||||||
|
|
||||||
preserve_hostname: false
|
|
||||||
manage_etc_hosts: false
|
|
||||||
fqdn: ${hostname}.${domain}
|
|
||||||
|
|
||||||
#cloud-config
|
|
||||||
# The above header must generally appear on the first line of a cloud config
|
|
||||||
# file, but all other lines that begin with a # are optional comments.
|
|
||||||
|
|
||||||
runcmd:
|
|
||||||
# One-command install, from https://tailscale.com/download/
|
|
||||||
- ['sh', '-c', 'curl -fsSL https://tailscale.com/install.sh | sh']
|
|
||||||
# Set sysctl settings for IP forwarding (useful when configuring an exit node)
|
|
||||||
- ['sh', '-c', "echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && sudo sysctl -p /etc/sysctl.d/99-tailscale.conf" ]
|
|
||||||
# Generate an auth key from your Admin console
|
|
||||||
# https://login.tailscale.com/admin/settings/keys
|
|
||||||
# and replace the placeholder below
|
|
||||||
- ['tailscale', 'up', '--auth-key=${TS_AUTHKEY}']
|
|
||||||
|
|
||||||
@@ -20,33 +20,23 @@ resource "proxmox_vm_qemu" "alpacas" {
|
|||||||
vmid = 500 + count.index + 1
|
vmid = 500 + count.index + 1
|
||||||
target_node = var.target_node
|
target_node = var.target_node
|
||||||
clone = var.clone_template
|
clone = var.clone_template
|
||||||
full_clone = true
|
full_clone = false
|
||||||
os_type = "cloud-init"
|
|
||||||
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_global.yaml"
|
cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml"
|
||||||
|
depends_on = [null_resource.upload_cloud_init_alpaca]
|
||||||
|
|
||||||
|
disk {
|
||||||
disks {
|
slot = "scsi0"
|
||||||
scsi {
|
type = "disk"
|
||||||
scsi0 {
|
storage = var.storage
|
||||||
disk {
|
size = var.disk_size
|
||||||
size = var.disk_size
|
|
||||||
storage = var.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scsi1 {
|
|
||||||
cloudinit {
|
|
||||||
storage = var.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network {
|
network {
|
||||||
@@ -63,32 +53,23 @@ resource "proxmox_vm_qemu" "llamas" {
|
|||||||
vmid = 600 + count.index + 1
|
vmid = 600 + count.index + 1
|
||||||
target_node = var.target_node
|
target_node = var.target_node
|
||||||
clone = var.clone_template
|
clone = var.clone_template
|
||||||
full_clone = true
|
full_clone = false
|
||||||
os_type = "cloud-init"
|
|
||||||
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_global.yaml"
|
cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml"
|
||||||
|
depends_on = [null_resource.upload_cloud_init_llama]
|
||||||
|
|
||||||
disks {
|
disk {
|
||||||
scsi {
|
slot = "scsi0"
|
||||||
scsi0 {
|
type = "disk"
|
||||||
disk {
|
storage = var.storage
|
||||||
size = var.disk_size
|
size = var.disk_size
|
||||||
storage = var.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scsi1 {
|
|
||||||
cloudinit {
|
|
||||||
storage = var.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network {
|
network {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": 4,
|
"version": 4,
|
||||||
"terraform_version": "1.8.3",
|
"terraform_version": "1.11.4",
|
||||||
"serial": 31,
|
"serial": 31,
|
||||||
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
|
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
target_node = "flex"
|
target_node = "flex"
|
||||||
clone_template = "ubuntu-cloudinit"
|
clone_template = "Alpine-TemplateV2"
|
||||||
vm_name = "alpine-vm"
|
vm_name = "alpine-vm"
|
||||||
cores = 1
|
cores = 2
|
||||||
memory = 1024
|
memory = 2048
|
||||||
disk_size = "15G"
|
disk_size = "15G"
|
||||||
sockets = 1
|
sockets = 1
|
||||||
bridge = "vmbr0"
|
bridge = "vmbr0"
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ variable "TS_AUTHKEY" {
|
|||||||
description = "Tailscale auth key used in cloud-init"
|
description = "Tailscale auth key used in cloud-init"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "SSK_KEY_PUBLIC" {
|
|
||||||
|
variable "ssh_key" {
|
||||||
type = string
|
type = string
|
||||||
description = "My Public SSH key fo ssh auth list"
|
description = "Public SSH key used by cloud-init"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user