Compare commits
34 Commits
destroy/no
...
8d9eea6728
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d9eea6728 | |||
|
|
96f6d94c3a | ||
| 8d49e447e6 | |||
|
|
99f3610a84 | ||
| d634e124a3 | |||
|
|
70b9b5e5b7 | ||
|
|
93d3f94100 | ||
| 70139b2693 | |||
|
|
8773f5026c | ||
| 1b6eca0f69 | |||
|
|
9551e0ad53 | ||
|
|
ffc1c1e785 | ||
| 3e55a72767 | |||
|
|
fcbd6a0b1d | ||
|
|
7227782d4f | ||
|
|
6dec58856e | ||
|
|
437d7ab8d1 | ||
|
|
ac2db5a1cf | ||
|
|
74b2fb8175 | ||
|
|
1acd33cb87 | ||
|
|
f9edeb8be5 | ||
|
|
661fb95830 | ||
|
|
50ae59602c | ||
|
|
507c102dad | ||
| b26ff582a4 | |||
|
|
ec07db08db | ||
| 114bfb9772 | |||
| 5509e14066 | |||
| df088a7903 | |||
| dcec6c3648 | |||
| a0ee1b8a4b | |||
| 39d4e2ac65 | |||
| 6d06cfac02 | |||
| e669353638 |
@@ -16,6 +16,7 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
TF_VAR_SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
TF_VAR_TS_AUTHKEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
TF_VAR_ssh_key: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
||||
@@ -17,10 +17,9 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
TF_VAR_TAILSCALE_KEY: ${{ secrets.TAILSCALE_KEY }}
|
||||
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
|
||||
|
||||
@@ -1,70 +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 = {
|
||||
ssh_key = var.ssh_key
|
||||
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 "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 = {
|
||||
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
|
||||
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 "local_file" "cloud_init_global" {
|
||||
content = data.template_file.cloud_init_global.rendered
|
||||
filename = "${path.module}/files/cloud_init_global.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
|
||||
|
||||
|
||||
6
terraform/files/cloud_init_base.yaml
Normal file
6
terraform/files/cloud_init_base.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --auth-key=${TS_AUTHKEY}
|
||||
- tailscale set --ssh
|
||||
|
||||
18
terraform/files/cloud_init_global.yaml
Normal file
18
terraform/files/cloud_init_global.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
#cloud-config
|
||||
hostname: ${hostname}
|
||||
fqdn: ${hostname}.${domain}
|
||||
|
||||
#cloud-config
|
||||
# The above header must generally appear on the first line of a cloud config
|
||||
# file, but all other lines that begin with a # are optional comments.
|
||||
|
||||
runcmd:
|
||||
# One-command install, from https://tailscale.com/download/
|
||||
- ['sh', '-c', 'curl -fsSL https://tailscale.com/install.sh | sh']
|
||||
# Set sysctl settings for IP forwarding (useful when configuring an exit node)
|
||||
- ['sh', '-c', "echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && sudo sysctl -p /etc/sysctl.d/99-tailscale.conf" ]
|
||||
# Generate an auth key from your Admin console
|
||||
# https://login.tailscale.com/admin/settings/keys
|
||||
# and replace the placeholder below
|
||||
- ['tailscale', 'up', '--auth-key=${TS_AUTHKEY}']
|
||||
|
||||
@@ -20,23 +20,32 @@ resource "proxmox_vm_qemu" "alpacas" {
|
||||
vmid = 500 + count.index + 1
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
full_clone = false
|
||||
full_clone = true
|
||||
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_global.yaml"
|
||||
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
storage = var.storage
|
||||
size = var.disk_size
|
||||
|
||||
disks {
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
scsi1 {
|
||||
cloudinit {
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network {
|
||||
@@ -53,23 +62,31 @@ resource "proxmox_vm_qemu" "llamas" {
|
||||
vmid = 600 + count.index + 1
|
||||
target_node = var.target_node
|
||||
clone = var.clone_template
|
||||
full_clone = false
|
||||
full_clone = true
|
||||
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_global.yaml"
|
||||
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
storage = var.storage
|
||||
size = var.disk_size
|
||||
disks {
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
size = var.disk_size
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
scsi1 {
|
||||
cloudinit {
|
||||
storage = var.storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network {
|
||||
|
||||
@@ -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": {},
|
||||
|
||||
@@ -79,9 +79,3 @@ variable "TS_AUTHKEY" {
|
||||
description = "Tailscale auth key used in cloud-init"
|
||||
}
|
||||
|
||||
|
||||
variable "ssh_key" {
|
||||
type = string
|
||||
description = "Public SSH key used by cloud-init"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user