From 507c102dad6314b7ebf120371c98cd2e2e57f8ad Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:01:52 +0100 Subject: [PATCH 01/11] terraform fmt --- terraform/cloud-init.tf | 56 ++++++++++++++++++++--------------------- terraform/variables.tf | 5 ++++ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 6c052e4..263b377 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -18,20 +18,20 @@ resource "local_file" "cloud_init_alpaca" { 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" - } -} +#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" { @@ -53,18 +53,18 @@ resource "local_file" "cloud_init_llama" { 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_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" +# } +#} diff --git a/terraform/variables.tf b/terraform/variables.tf index bf1ab3a..7bd76d2 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -2,6 +2,11 @@ variable "proxmox_password" { type = string } +variable "proxmox_ssh_private_key" { + type = string + description = "Unencrypted SSH private key used for root@flex upload" +} + variable "target_node" { type = string } From 50ae59602c66f18b31185dedafb1af4b33013aac Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:03:28 +0100 Subject: [PATCH 02/11] terraform fmt --- terraform/files/cloud_init_base.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 terraform/files/cloud_init_base.yaml diff --git a/terraform/files/cloud_init_base.yaml b/terraform/files/cloud_init_base.yaml new file mode 100644 index 0000000..2df9bd8 --- /dev/null +++ b/terraform/files/cloud_init_base.yaml @@ -0,0 +1,11 @@ +#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 + From 661fb95830049f5124d76bca65a8b9d4680246df Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:05:13 +0100 Subject: [PATCH 03/11] terraform fmt --- terraform/main.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 5196fea..529c9fd 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -30,7 +30,6 @@ resource "proxmox_vm_qemu" "alpacas" { boot = "order=scsi0" ipconfig0 = "ip=dhcp" cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml" - depends_on = [null_resource.upload_cloud_init_alpaca] disk { slot = "scsi0" @@ -63,7 +62,6 @@ resource "proxmox_vm_qemu" "llamas" { boot = "order=scsi0" ipconfig0 = "ip=dhcp" cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml" - depends_on = [null_resource.upload_cloud_init_llama] disk { slot = "scsi0" From f9edeb8be58132263e23991c35c7bbc3ec9908d4 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:07:17 +0100 Subject: [PATCH 04/11] terraform fmt --- terraform/main.tf | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 529c9fd..f7bc127 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -23,13 +23,13 @@ resource "proxmox_vm_qemu" "alpacas" { full_clone = false agent = 1 - sockets = var.sockets - cores = var.cores - memory = var.memory - scsihw = "virtio-scsi-pci" - boot = "order=scsi0" - ipconfig0 = "ip=dhcp" - cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml" + sockets = var.sockets + cores = var.cores + memory = var.memory + scsihw = "virtio-scsi-pci" + boot = "order=scsi0" + ipconfig0 = "ip=dhcp" + cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml" disk { slot = "scsi0" @@ -55,13 +55,13 @@ resource "proxmox_vm_qemu" "llamas" { full_clone = false agent = 1 - sockets = var.sockets - cores = var.cores - memory = var.memory - scsihw = "virtio-scsi-pci" - boot = "order=scsi0" - ipconfig0 = "ip=dhcp" - cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml" + sockets = var.sockets + cores = var.cores + memory = var.memory + scsihw = "virtio-scsi-pci" + boot = "order=scsi0" + ipconfig0 = "ip=dhcp" + cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml" disk { slot = "scsi0" From 1acd33cb877c66c652d7fcfd0cdf35bb3367a213 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:12:37 +0100 Subject: [PATCH 05/11] terraform fmt --- terraform/cloud-init.tf | 2 -- terraform/variables.tf | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 263b377..6a99e5a 100644 --- a/terraform/cloud-init.tf +++ b/terraform/cloud-init.tf @@ -4,7 +4,6 @@ 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" TS_AUTHKEY = var.TS_AUTHKEY @@ -39,7 +38,6 @@ 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" TS_AUTHKEY = var.TS_AUTHKEY diff --git a/terraform/variables.tf b/terraform/variables.tf index 7bd76d2..faacfdc 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -2,11 +2,6 @@ variable "proxmox_password" { type = string } -variable "proxmox_ssh_private_key" { - type = string - description = "Unencrypted SSH private key used for root@flex upload" -} - variable "target_node" { type = string } @@ -84,9 +79,3 @@ variable "TS_AUTHKEY" { 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" -} - From 74b2fb81753e01d9e3889bed685f1f5d479cd5a9 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:17:29 +0100 Subject: [PATCH 06/11] terraform fmt --- terraform/files/cloud_init_base.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/terraform/files/cloud_init_base.yaml b/terraform/files/cloud_init_base.yaml index 2df9bd8..a4d9277 100644 --- a/terraform/files/cloud_init_base.yaml +++ b/terraform/files/cloud_init_base.yaml @@ -1,8 +1,6 @@ #cloud-config hostname: ${hostname} fqdn: ${hostname}.${domain} -ssh_authorized_keys: - - ${ssh_key} runcmd: - curl -fsSL https://tailscale.com/install.sh | sh From ac2db5a1cf88a23fdeacc102f51896f1da1af41a Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:21:16 +0100 Subject: [PATCH 07/11] terraform fmt --- .gitea/workflows/terraform-plan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/terraform-plan.yml b/.gitea/workflows/terraform-plan.yml index 267f57c..04f0cbe 100644 --- a/.gitea/workflows/terraform-plan.yml +++ b/.gitea/workflows/terraform-plan.yml @@ -19,7 +19,7 @@ jobs: env: TF_VAR_SSH_KEY: ${{ secrets.SSH_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 From 437d7ab8d17a78fb93e9f483d8487ac45a3cbb49 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:24:03 +0100 Subject: [PATCH 08/11] terraform fmt --- .gitea/workflows/terraform-plan.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/terraform-plan.yml b/.gitea/workflows/terraform-plan.yml index 04f0cbe..8a45386 100644 --- a/.gitea/workflows/terraform-plan.yml +++ b/.gitea/workflows/terraform-plan.yml @@ -49,7 +49,8 @@ jobs: - name: Terraform Plan working-directory: terraform - run: terraform plan -out=tfplan + run: terraform apply -target=local_file.cloud_init_alpaca -target=local_file.cloud_init_llama + - name: Upload Terraform Plan uses: actions/upload-artifact@v3 From 6dec58856e787f3341d159c928db4d930d7efccf Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:36:10 +0100 Subject: [PATCH 09/11] terraform fmt --- terraform/files/cloud_init.yaml | 10 ---------- terraform/terraform.tfstate | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 terraform/files/cloud_init.yaml diff --git a/terraform/files/cloud_init.yaml b/terraform/files/cloud_init.yaml deleted file mode 100644 index bfc7eb9..0000000 --- a/terraform/files/cloud_init.yaml +++ /dev/null @@ -1,10 +0,0 @@ -#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} - diff --git a/terraform/terraform.tfstate b/terraform/terraform.tfstate index 19d9355..06358c8 100644 --- a/terraform/terraform.tfstate +++ b/terraform/terraform.tfstate @@ -1,6 +1,6 @@ { "version": 4, - "terraform_version": "1.11.4", + "terraform_version": "1.8.3", "serial": 31, "lineage": "7a39dd41-1655-172c-950b-b8c5398caf69", "outputs": {}, From 7227782d4ffa58f1ff999fd92821d4b4678b3fee Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:38:13 +0100 Subject: [PATCH 10/11] terraform fmt --- terraform/files/cloud_init.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 terraform/files/cloud_init.yaml diff --git a/terraform/files/cloud_init.yaml b/terraform/files/cloud_init.yaml new file mode 100644 index 0000000..a4d9277 --- /dev/null +++ b/terraform/files/cloud_init.yaml @@ -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 + From fcbd6a0b1d33d58eb85e3a0cd755ec38c0fd0d87 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Thu, 17 Apr 2025 20:39:32 +0100 Subject: [PATCH 11/11] terraform fmt --- .gitea/workflows/terraform-plan.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitea/workflows/terraform-plan.yml b/.gitea/workflows/terraform-plan.yml index 8a45386..04f0cbe 100644 --- a/.gitea/workflows/terraform-plan.yml +++ b/.gitea/workflows/terraform-plan.yml @@ -49,8 +49,7 @@ jobs: - name: Terraform Plan working-directory: terraform - run: terraform apply -target=local_file.cloud_init_alpaca -target=local_file.cloud_init_llama - + run: terraform plan -out=tfplan - name: Upload Terraform Plan uses: actions/upload-artifact@v3