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

Reviewed-on: #14
This commit is contained in:
micqdf 2025-04-17 21:29:51 +00:00
commit d634e124a3
4 changed files with 20 additions and 64 deletions

View File

@ -1,68 +1,17 @@
### Alpaca cloud-init template
data "template_file" "cloud_init_alpaca" {
count = var.alpaca_vm_count
template = file("${path.module}/files/cloud_init.yaml")
### Global cloud-init template (for all VMs)
data "template_file" "cloud_init_global" {
template = file("${path.module}/files/cloud_init_global.yaml")
vars = {
hostname = "alpaca-${count.index + 1}"
hostname = "generic"
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
filename = "${path.module}/files/cloud_init_alpaca_${count.index + 1}.yaml"
resource "local_file" "cloud_init_global" {
content = data.template_file.cloud_init_global.rendered
filename = "${path.module}/files/cloud_init_global.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 = {
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"
# }
#}

View File

@ -1,7 +1,4 @@
#cloud-config
hostname: ${hostname}
fqdn: ${hostname}.${domain}
runcmd:
- curl -fsSL https://tailscale.com/install.sh | sh
- tailscale up --auth-key=${TS_AUTHKEY}

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

@ -29,7 +29,8 @@ resource "proxmox_vm_qemu" "alpacas" {
scsihw = "virtio-scsi-pci"
boot = "order=scsi0"
ipconfig0 = "ip=dhcp"
cicustom = "user=local:snippets/cloud_init_alpaca_${count.index + 1}.yaml"
cicustom = "user=local:snippets/cloud_init_global.yaml"
disks {
scsi {
@ -71,7 +72,7 @@ resource "proxmox_vm_qemu" "llamas" {
scsihw = "virtio-scsi-pci"
boot = "order=scsi0"
ipconfig0 = "ip=dhcp"
cicustom = "user=local:snippets/cloud_init_llama_${count.index + 1}.yaml"
cicustom = "user=local:snippets/cloud_init_global.yaml"
disks {
scsi {