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 diff --git a/terraform/cloud-init.tf b/terraform/cloud-init.tf index 6c052e4..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 @@ -18,20 +17,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" { @@ -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 @@ -53,18 +51,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/files/cloud_init.yaml b/terraform/files/cloud_init.yaml index bfc7eb9..a4d9277 100644 --- a/terraform/files/cloud_init.yaml +++ b/terraform/files/cloud_init.yaml @@ -1,10 +1,9 @@ #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 diff --git a/terraform/files/cloud_init_base.yaml b/terraform/files/cloud_init_base.yaml new file mode 100644 index 0000000..a4d9277 --- /dev/null +++ b/terraform/files/cloud_init_base.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 + diff --git a/terraform/main.tf b/terraform/main.tf index 5196fea..f7bc127 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -23,14 +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" - depends_on = [null_resource.upload_cloud_init_alpaca] + 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" @@ -56,14 +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" - depends_on = [null_resource.upload_cloud_init_llama] + 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" 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": {}, diff --git a/terraform/variables.tf b/terraform/variables.tf index bf1ab3a..faacfdc 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -79,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" -} -