mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-07 21:13:12 +00:00
b3005e1e72
Replace 4 per-node auto-install ISOs (~4GB) with 2 generic ISOs (~2GB) served by an HTTP answer server that routes per-node configs by MAC address. New flow: 1. Deterministic MAC addresses assigned per node (AA:BB:CC:00:VV:NN) 2. Per-MAC answer.toml files generated in answers/ directory 3. HTTP answer server (slothcroissant/proxmox-auto-installer-server) managed by Terraform, serves answer files on port 8000 4. Generic ISOs prepared with --fetch-from http --url pointing to the answer server 5. PVE installer POSTs system info, server matches MAC to answer file Benefits: - 50% reduction in ISO disk/tmp usage (2 ISOs instead of 4) - Faster ISO preparation (2 builds instead of 4) - Answer files can be updated without rebuilding ISOs - First-boot script embedded in generic ISO via --on-first-boot Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
105 lines
3.1 KiB
Terraform
105 lines
3.1 KiB
Terraform
# ── Answer server container ──────────────────────────────────────────
|
|
|
|
resource "docker_container" "answer_server" {
|
|
name = "pvetest-answer-server"
|
|
image = "slothcroissant/proxmox-auto-installer-server:latest"
|
|
restart = "unless-stopped"
|
|
|
|
network_mode = "host"
|
|
|
|
volumes {
|
|
host_path = var.answer_files_dir
|
|
container_path = "/app/answers"
|
|
}
|
|
|
|
volumes {
|
|
host_path = var.default_answer_file
|
|
container_path = "/app/default.toml"
|
|
}
|
|
}
|
|
|
|
# ── Docker images & volumes ──────────────────────────────────────────
|
|
|
|
resource "docker_image" "ubuntu" {
|
|
name = "ubuntu:24.04"
|
|
}
|
|
|
|
resource "docker_volume" "iscsi_data" {
|
|
name = "pvetest-iscsi-data"
|
|
}
|
|
|
|
resource "docker_volume" "nfs_data" {
|
|
name = "pvetest-nfs-data"
|
|
}
|
|
|
|
# ── iSCSI target container ──────────────────────────────────────────
|
|
|
|
resource "docker_container" "iscsi_target" {
|
|
name = "pvetest-iscsi"
|
|
image = docker_image.ubuntu.image_id
|
|
privileged = true
|
|
restart = "unless-stopped"
|
|
|
|
network_mode = "host"
|
|
|
|
volumes {
|
|
volume_name = docker_volume.iscsi_data.name
|
|
container_path = "/srv/iscsi"
|
|
}
|
|
|
|
env = [
|
|
"ISCSI_IQN=${var.storage_iscsi_iqn}",
|
|
"ISCSI_LUN_SIZE=${var.storage_iscsi_lun_size}",
|
|
]
|
|
|
|
entrypoint = ["/bin/bash", "-c"]
|
|
command = [<<-EOT
|
|
set -e
|
|
apt-get update -qq && apt-get install -y -qq tgt >/dev/null 2>&1
|
|
mkdir -p /srv/iscsi
|
|
if [ ! -f /srv/iscsi/lun0.img ]; then
|
|
truncate -s $${ISCSI_LUN_SIZE} /srv/iscsi/lun0.img
|
|
fi
|
|
tgtd --foreground &
|
|
sleep 2
|
|
if ! tgtadm --lld iscsi --op show --mode target | grep -q "Target 1: $${ISCSI_IQN}"; then
|
|
tgtadm --lld iscsi --op new --mode target --tid 1 -T $${ISCSI_IQN}
|
|
fi
|
|
if ! tgtadm --lld iscsi --op show --mode logicalunit --tid 1 2>/dev/null | grep -qE "LUN:[[:space:]]*1($$|[^0-9])"; then
|
|
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /srv/iscsi/lun0.img
|
|
fi
|
|
if ! tgtadm --lld iscsi --op show --mode target --tid 1 2>/dev/null | grep -q "Initiator-address: ALL"; then
|
|
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
|
|
fi
|
|
echo "iSCSI target ready: $${ISCSI_IQN} (port 3260)"
|
|
wait
|
|
EOT
|
|
]
|
|
}
|
|
|
|
# ── NFS server container ────────────────────────────────────────────
|
|
|
|
resource "docker_container" "nfs_server" {
|
|
name = "pvetest-nfs"
|
|
image = "erichough/nfs-server:2.2.1"
|
|
privileged = true
|
|
restart = "unless-stopped"
|
|
|
|
network_mode = "host"
|
|
|
|
volumes {
|
|
volume_name = docker_volume.nfs_data.name
|
|
container_path = "/srv/nfs/shared"
|
|
}
|
|
|
|
volumes {
|
|
host_path = "/lib/modules"
|
|
container_path = "/lib/modules"
|
|
read_only = true
|
|
}
|
|
|
|
env = [
|
|
"NFS_EXPORT_0=/srv/nfs/shared *(rw,sync,no_subtree_check,no_root_squash)",
|
|
]
|
|
}
|