diff --git a/.gitea/workflows/terraform-plan.yml b/.gitea/workflows/terraform-plan.yml index 5456fb2..9f8a56b 100644 --- a/.gitea/workflows/terraform-plan.yml +++ b/.gitea/workflows/terraform-plan.yml @@ -17,8 +17,10 @@ jobs: 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 }} - TF_VAR_tailscale_key: ${{ secrets.TAILSCALE_KEY }} + steps: - name: Checkout repository diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 553b9b8..3950b62 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -4,13 +4,14 @@ data "template_file" "cloud_init_alpaca" { template = file("${path.module}/files/cloud_init.yaml") vars = { - ssh_key = var.ssh_key - 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 @@ -38,13 +39,14 @@ data "template_file" "cloud_init_llama" { template = file("${path.module}/files/cloud_init.yaml") vars = { - ssh_key = var.ssh_key - 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 diff --git a/terraform/variables.tf b/terraform/variables.tf index 6369347..397e4f8 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -74,11 +74,12 @@ 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"