Compare commits

..

No commits in common. "d634e124a3c4148b9a51431dac87da1707cfe3d6" and "70139b26939682ef42329e7e9d27df6396878640" have entirely different histories.

4 changed files with 64 additions and 20 deletions

View File

@ -1,17 +1,68 @@
### Global cloud-init template (for all VMs)
data "template_file" "cloud_init_global" {
template = file("${path.module}/files/cloud_init_global.yaml")
### Alpaca cloud-init template
data "template_file" "cloud_init_alpaca" {
count = var.alpaca_vm_count
template = file("${path.module}/files/cloud_init.yaml")
vars = {
hostname = "generic"
hostname = "alpaca-${count.index + 1}"
domain = "home.arpa"
TS_AUTHKEY = var.TS_AUTHKEY
}
}
resource "local_file" "cloud_init_global" {
content = data.template_file.cloud_init_global.rendered
filename = "${path.module}/files/cloud_init_global.yaml"
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 "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,4 +1,7 @@
#cloud-config
hostname: ${hostname}
fqdn: ${hostname}.${domain}
runcmd:
- curl -fsSL https://tailscale.com/install.sh | sh
- tailscale up --auth-key=${TS_AUTHKEY}

View File

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