Merge pull request 'stage' (#11) from stage into master
All checks were successful
Gitea Actions Demo / Terraform Apply (push) Successful in 5m57s

Reviewed-on: #11
This commit is contained in:
micqdf 2025-04-17 20:27:27 +00:00
commit 3e55a72767
7 changed files with 54 additions and 56 deletions

View File

@ -19,7 +19,7 @@ jobs:
env: env:
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }} 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

View File

@ -4,7 +4,6 @@ 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 = var.SSH_KEY
hostname = "alpaca-${count.index + 1}" hostname = "alpaca-${count.index + 1}"
domain = "home.arpa" domain = "home.arpa"
TS_AUTHKEY = var.TS_AUTHKEY TS_AUTHKEY = var.TS_AUTHKEY
@ -18,20 +17,20 @@ resource "local_file" "cloud_init_alpaca" {
filename = "${path.module}/files/cloud_init_alpaca_${count.index + 1}.yaml" filename = "${path.module}/files/cloud_init_alpaca_${count.index + 1}.yaml"
} }
resource "null_resource" "upload_cloud_init_alpaca" { #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"
host = var.target_node # host = var.target_node
} # }
#
provisioner "file" { # provisioner "file" {
source = local_file.cloud_init_alpaca[count.index].filename # source = local_file.cloud_init_alpaca[count.index].filename
destination = "/var/lib/vz/snippets/cloud_init_alpaca_${count.index + 1}.yaml" # destination = "/var/lib/vz/snippets/cloud_init_alpaca_${count.index + 1}.yaml"
} # }
} #}
### Llama cloud-init template ### Llama cloud-init template
data "template_file" "cloud_init_llama" { data "template_file" "cloud_init_llama" {
@ -39,7 +38,6 @@ 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 = var.SSH_KEY
hostname = "llama-${count.index + 1}" hostname = "llama-${count.index + 1}"
domain = "home.arpa" domain = "home.arpa"
TS_AUTHKEY = var.TS_AUTHKEY TS_AUTHKEY = var.TS_AUTHKEY
@ -53,18 +51,18 @@ resource "local_file" "cloud_init_llama" {
filename = "${path.module}/files/cloud_init_llama_${count.index + 1}.yaml" filename = "${path.module}/files/cloud_init_llama_${count.index + 1}.yaml"
} }
resource "null_resource" "upload_cloud_init_llama" { #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"
host = var.target_node # host = var.target_node
} # }
#
provisioner "file" { # provisioner "file" {
source = local_file.cloud_init_llama[count.index].filename # source = local_file.cloud_init_llama[count.index].filename
destination = "/var/lib/vz/snippets/cloud_init_llama_${count.index + 1}.yaml" # destination = "/var/lib/vz/snippets/cloud_init_llama_${count.index + 1}.yaml"
} # }
} #}

View File

@ -1,10 +1,9 @@
#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

View File

@ -0,0 +1,9 @@
#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

View File

@ -23,14 +23,13 @@ resource "proxmox_vm_qemu" "alpacas" {
full_clone = false full_clone = false
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_alpaca_${count.index + 1}.yaml" cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml"
depends_on = [null_resource.upload_cloud_init_alpaca]
disk { disk {
slot = "scsi0" slot = "scsi0"
@ -56,14 +55,13 @@ resource "proxmox_vm_qemu" "llamas" {
full_clone = false full_clone = false
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_llama_${count.index + 1}.yaml" cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml"
depends_on = [null_resource.upload_cloud_init_llama]
disk { disk {
slot = "scsi0" slot = "scsi0"

View File

@ -1,6 +1,6 @@
{ {
"version": 4, "version": 4,
"terraform_version": "1.11.4", "terraform_version": "1.8.3",
"serial": 31, "serial": 31,
"lineage": "7a39dd41-1655-172c-950b-b8c5398caf69", "lineage": "7a39dd41-1655-172c-950b-b8c5398caf69",
"outputs": {}, "outputs": {},

View File

@ -79,9 +79,3 @@ variable "TS_AUTHKEY" {
description = "Tailscale auth key used in cloud-init" description = "Tailscale auth key used in cloud-init"
} }
variable "SSH_KEY" {
type = string
description = "Private SSH key used to upload cloud-init files to Proxmox"
}