Add infrastructure packages: terraform-pve, ansible-push, wolfstack-keepalived, terraform-pve-vm
This commit is contained in:
11
artemis-backup-20260614-1920/terraform-pve-vm/CHECKPOINT.md
Normal file
11
artemis-backup-20260614-1920/terraform-pve-vm/CHECKPOINT.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# CHECKPOINT — Terraform PVE VM Deployment
|
||||
**Session date:** 2026-06-12
|
||||
**Chunk:** 1 of 5 — PRD Draft written
|
||||
**Next chunk:** 2 — Await Bobby review on PRD decision points, then build Terraform files
|
||||
**Files modified:**
|
||||
- ~/documentation/PRD Drafts/terraform-pve-vm-deployment.md (new)
|
||||
**Blockers:** None — awaiting Bobby approval on:
|
||||
1. Cloud image download method (wget per node vs NAS)
|
||||
2. Disk format (raw vs qcow2)
|
||||
3. BIOS vs EFI
|
||||
4. QEMU Guest Agent enablement
|
||||
5
artemis-backup-20260614-1920/terraform-pve-vm/Dockerfile
Normal file
5
artemis-backup-20260614-1920/terraform-pve-vm/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM hashicorp/terraform:latest
|
||||
|
||||
RUN apk add --no-cache openssh-client
|
||||
|
||||
WORKDIR /workspace
|
||||
@@ -0,0 +1,12 @@
|
||||
services:
|
||||
terraform:
|
||||
build: .
|
||||
container_name: terraform-pve-vm
|
||||
volumes:
|
||||
- ./terraform:/workspace
|
||||
- ~/.ssh/artemis_key.pub:/workspace/artemis_key.pub:ro
|
||||
working_dir: /workspace
|
||||
network_mode: host
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: ["version"]
|
||||
22
artemis-backup-20260614-1920/terraform-pve-vm/run.sh
Normal file
22
artemis-backup-20260614-1920/terraform-pve-vm/run.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
case "${1:-plan}" in
|
||||
init|validate|plan|apply|destroy)
|
||||
docker compose run --rm terraform "$1" "${@:2}"
|
||||
;;
|
||||
shell)
|
||||
docker compose run --rm terraform /bin/sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [init|validate|plan|apply|destroy|shell]"
|
||||
echo ""
|
||||
echo "Runtime overrides via -var flags:"
|
||||
echo " $0 apply -auto-approve \\"
|
||||
echo " -var=\"node=mk34\" \\"
|
||||
echo " -var=\"vmid_base=3035\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,90 @@
|
||||
locals {
|
||||
# VM definitions: name, node, vmid, static IP
|
||||
vms = {
|
||||
for idx, suffix in var.name_suffixes : "vm-${suffix}" => {
|
||||
name = "${var.name_prefix}-${suffix}"
|
||||
node = element(["mk33", "mk34", "mk39"], idx)
|
||||
vmid = var.vmid_base + idx
|
||||
ipv4 = "${var.subnet_prefix}.30.${var.vmid_base + idx}/18"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
|
||||
for_each = local.vms
|
||||
|
||||
name = each.value.name
|
||||
node_name = each.value.node
|
||||
vm_id = each.value.vmid
|
||||
|
||||
tags = concat(var.tags, [each.key])
|
||||
|
||||
# ── CPU / Memory ──────────────────────────
|
||||
cpu {
|
||||
cores = var.cores
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = var.memory
|
||||
}
|
||||
|
||||
# ── QEMU Guest Agent ──────────────────────
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# ── Boot / EFI ────────────────────────────
|
||||
bios = "ovmf"
|
||||
|
||||
efi_disk {
|
||||
datastore_id = var.storage
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
machine = "q35"
|
||||
|
||||
# ── SCSI Controller ───────────────────────
|
||||
scsi_hardware = "virtio-scsi-single"
|
||||
|
||||
# ── Disk (Cloud-init image) ───────────────
|
||||
disk {
|
||||
datastore_id = var.storage
|
||||
file_id = var.cloud_image_id
|
||||
interface = "scsi0"
|
||||
iothread = true
|
||||
discard = "on"
|
||||
size = var.disk_size
|
||||
}
|
||||
|
||||
# ── Network ─────────────────────────────────
|
||||
network_device {
|
||||
bridge = var.bridge
|
||||
}
|
||||
|
||||
# ── VGA / Console ─────────────────────────
|
||||
vga {
|
||||
type = "std"
|
||||
}
|
||||
|
||||
# ── Cloud-Init ─────────────────────────────
|
||||
initialization {
|
||||
datastore_id = var.cloudinit_storage
|
||||
|
||||
user_account {
|
||||
username = "jarvis"
|
||||
password = "ubuntu"
|
||||
keys = [file(var.ssh_key_path)]
|
||||
}
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = each.value.ipv4
|
||||
gateway = var.gateway
|
||||
}
|
||||
}
|
||||
|
||||
dns {
|
||||
servers = var.dns_servers
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
output "vm_names" {
|
||||
description = "Created VM names"
|
||||
value = [for vm in proxmox_virtual_environment_vm.ubuntu_vm : vm.name]
|
||||
}
|
||||
|
||||
output "vm_ids" {
|
||||
description = "Created VM IDs"
|
||||
value = [for vm in proxmox_virtual_environment_vm.ubuntu_vm : vm.vm_id]
|
||||
}
|
||||
|
||||
output "vm_nodes" {
|
||||
description = "PVE nodes hosting each VM"
|
||||
value = { for k, vm in proxmox_virtual_environment_vm.ubuntu_vm : k => vm.node_name }
|
||||
}
|
||||
|
||||
output "vm_ipv4" {
|
||||
description = "Static IPv4 addresses"
|
||||
value = { for k, vm in proxmox_virtual_environment_vm.ubuntu_vm : k => vm.initialization[0].ip_config[0].ipv4[0].address }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.70.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.pm_api_url
|
||||
api_token = "${var.pm_api_token_id}=${var.pm_api_token_secret}"
|
||||
insecure = true
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
variable "pm_api_url" {
|
||||
description = "Proxmox API URL"
|
||||
type = string
|
||||
default = "https://192.168.7.33:8006/api2/json"
|
||||
}
|
||||
|
||||
variable "pm_api_token_id" {
|
||||
description = "Proxmox API token ID"
|
||||
type = string
|
||||
default = "root@pam!terraform"
|
||||
}
|
||||
|
||||
variable "pm_api_token_secret" {
|
||||
description = "Proxmox API token secret"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "node" {
|
||||
description = "Target PVE node"
|
||||
type = string
|
||||
default = "mk33"
|
||||
}
|
||||
|
||||
variable "vmid_base" {
|
||||
description = "Starting VMID for the first VM"
|
||||
type = number
|
||||
default = 3034
|
||||
}
|
||||
|
||||
variable "vm_count" {
|
||||
description = "Number of VMs to create"
|
||||
type = number
|
||||
default = 3
|
||||
}
|
||||
|
||||
variable "name_prefix" {
|
||||
description = "Hostname prefix for VMs"
|
||||
type = string
|
||||
default = "vm"
|
||||
}
|
||||
|
||||
variable "name_suffixes" {
|
||||
description = "Per-VM name suffixes (artemis, jarvis, friday)"
|
||||
type = list(string)
|
||||
default = ["artemis", "jarvis", "friday"]
|
||||
}
|
||||
|
||||
variable "subnet_prefix" {
|
||||
description = "First two octets of IPv4"
|
||||
type = string
|
||||
default = "192.168"
|
||||
}
|
||||
|
||||
variable "cores" {
|
||||
description = "CPU cores per VM"
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
description = "RAM in MB per VM"
|
||||
type = number
|
||||
default = 4096
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
description = "Disk size in GB"
|
||||
type = number
|
||||
default = 64
|
||||
}
|
||||
|
||||
variable "storage" {
|
||||
description = "Storage pool for VM disk"
|
||||
type = string
|
||||
default = "local"
|
||||
}
|
||||
|
||||
variable "bridge" {
|
||||
description = "Network bridge"
|
||||
type = string
|
||||
default = "vmbr0"
|
||||
}
|
||||
|
||||
variable "gateway" {
|
||||
description = "IPv4 gateway"
|
||||
type = string
|
||||
default = "192.168.18.1"
|
||||
}
|
||||
|
||||
variable "dns_servers" {
|
||||
description = "DNS servers"
|
||||
type = list(string)
|
||||
default = ["192.168.7.7", "1.1.1.1"]
|
||||
}
|
||||
|
||||
variable "ssh_key_path" {
|
||||
description = "Path to SSH public key for jarvis user"
|
||||
type = string
|
||||
default = "artemis_key.pub"
|
||||
}
|
||||
|
||||
variable "cloud_image_id" {
|
||||
description = "Cloud-init image file ID on storage (storage:path)"
|
||||
type = string
|
||||
default = "local:iso/noble-server-cloudimg-amd64.img"
|
||||
}
|
||||
|
||||
variable "cloudinit_storage" {
|
||||
description = "Storage pool for cloud-init drive"
|
||||
type = string
|
||||
default = "local"
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Base tags for all VMs"
|
||||
type = list(string)
|
||||
default = ["terraform", "cloudinit-vm"]
|
||||
}
|
||||
Reference in New Issue
Block a user