add homepage dashboard alongside heimdall
This commit is contained in:
parent
200e11d23c
commit
d291d83356
|
|
@ -13,10 +13,12 @@ locals {
|
|||
crowdsec_acquis = templatefile("${path.module}/templates/crowdsec-acquis.yaml.tftpl", {})
|
||||
crowdsec_whitelist = templatefile("${path.module}/templates/crowdsec-homelab-whitelist.yaml.tftpl", {})
|
||||
heimdall_server_name = "heimdall.${var.server_name}"
|
||||
homepage_server_name = "homepage.${var.server_name}"
|
||||
heimdall_backend_host = var.heimdall_backend_host != "" ? var.heimdall_backend_host : var.gitea_backend_host
|
||||
homepage_backend_host = var.homepage_backend_host != "" ? var.homepage_backend_host : var.gitea_backend_host
|
||||
server_names = distinct(concat([var.server_name, local.heimdall_server_name], var.additional_server_names))
|
||||
matrix_server_names = var.matrix_enabled ? [var.matrix_server_name, var.element_server_name] : []
|
||||
main_server_names = [for name in local.server_names : name if name != local.heimdall_server_name && !contains(local.matrix_server_names, name)]
|
||||
main_server_names = [for name in local.server_names : name if !contains([local.heimdall_server_name, local.homepage_server_name], name) && !contains(local.matrix_server_names, name)]
|
||||
default_conf = templatefile("${path.module}/templates/default.conf.tftpl", {
|
||||
server_name = var.server_name
|
||||
server_names = join(" ", local.server_names)
|
||||
|
|
@ -29,6 +31,9 @@ locals {
|
|||
heimdall_server_name = local.heimdall_server_name
|
||||
heimdall_backend_host = local.heimdall_backend_host
|
||||
heimdall_backend_port = tostring(var.heimdall_backend_port)
|
||||
homepage_server_name = local.homepage_server_name
|
||||
homepage_backend_host = local.homepage_backend_host
|
||||
homepage_backend_port = tostring(var.homepage_backend_port)
|
||||
})
|
||||
default_vcl = templatefile("${path.module}/templates/default.vcl.tftpl", {
|
||||
backend_host = var.backend_host
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ upstream heimdall_backend {
|
|||
keepalive 8;
|
||||
}
|
||||
|
||||
upstream homepage_backend {
|
||||
server ${homepage_backend_host}:${homepage_backend_port};
|
||||
keepalive 8;
|
||||
}
|
||||
|
||||
set_real_ip_from 173.245.48.0/20;
|
||||
set_real_ip_from 103.21.244.0/22;
|
||||
set_real_ip_from 103.22.200.0/22;
|
||||
|
|
@ -58,7 +63,7 @@ server {
|
|||
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${heimdall_server_name};
|
||||
server_name ${heimdall_server_name} ${homepage_server_name};
|
||||
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
|
|
@ -119,6 +124,54 @@ server {
|
|||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name ${homepage_server_name};
|
||||
|
||||
ssl_certificate /etc/nginx/certs/current.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/current.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_session_cache shared:homelab_ssl:10m;
|
||||
ssl_session_timeout 1d;
|
||||
|
||||
keepalive_timeout 65s;
|
||||
keepalive_requests 1000;
|
||||
|
||||
if ($blocked_uris) { return 403; }
|
||||
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||
add_header Permissions-Policy "geolocation=(), microphone=()";
|
||||
|
||||
gzip on;
|
||||
gzip_comp_level 2;
|
||||
gzip_min_length 1000;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
location = /edge-health {
|
||||
access_log off;
|
||||
return 204;
|
||||
}
|
||||
|
||||
location / {
|
||||
limit_req zone=one burst=20 nodelay;
|
||||
|
||||
proxy_pass http://homepage_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ variable "heimdall_backend_port" {
|
|||
default = 8082
|
||||
}
|
||||
|
||||
variable "homepage_backend_host" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "homepage_backend_port" {
|
||||
type = number
|
||||
default = 8083
|
||||
}
|
||||
|
||||
# Matrix (isolated vhost + its own cert; does NOT touch shared current.crt)
|
||||
variable "matrix_enabled" {
|
||||
type = bool
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ domain:
|
|||
subdomains:
|
||||
- demos.lab2025.duckdns.org
|
||||
- heimdall.lab2025.duckdns.org
|
||||
- homepage.lab2025.duckdns.org
|
||||
- matrix.lab2025.duckdns.org
|
||||
- element.lab2025.duckdns.org
|
||||
- grafana.lab2025.duckdns.org
|
||||
|
|
@ -79,6 +80,11 @@ services:
|
|||
install_dir: /data/homelab-heimdall
|
||||
http_port: 8082
|
||||
public_url: https://heimdall.lab2025.duckdns.org/
|
||||
homepage:
|
||||
host: debian
|
||||
install_dir: /data/homelab-heimdall
|
||||
http_port: 8083
|
||||
public_url: https://homepage.lab2025.duckdns.org/
|
||||
gitops_mirror:
|
||||
host: debian
|
||||
path: /home/jv/git-server/my-homelab-configs.git
|
||||
|
|
|
|||
|
|
@ -16,6 +16,23 @@ services:
|
|||
networks:
|
||||
- heimdall
|
||||
|
||||
homepage:
|
||||
image: ${HOMEPAGE_IMAGE:-ghcr.io/gethomepage/homepage:v1.5.0}
|
||||
container_name: ${HOMEPAGE_CONTAINER_NAME:-homelab-homepage}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
PUID: ${HOMEPAGE_UID:-1000}
|
||||
PGID: ${HOMEPAGE_GID:-1000}
|
||||
TZ: ${TZ:-America/Mexico_City}
|
||||
HOMEPAGE_ALLOWED_HOSTS: ${HOMEPAGE_ALLOWED_HOSTS:-homepage.lab2025.duckdns.org,127.0.0.1:8083,localhost:8083}
|
||||
ports:
|
||||
- "${HOMEPAGE_BIND_IP:-0.0.0.0}:${HOMEPAGE_HTTP_PORT:-8083}:3000/tcp"
|
||||
volumes:
|
||||
- ${HOMEPAGE_CONFIG_DIR:-/data/homelab-heimdall/homepage/config}:/app/config
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
networks:
|
||||
- heimdall
|
||||
|
||||
link-seeder:
|
||||
image: ${HEIMDALL_SEEDER_IMAGE:-python:3.12-alpine}
|
||||
container_name: ${HEIMDALL_SEEDER_CONTAINER_NAME:-homelab-heimdall-link-seeder}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
- Homelab:
|
||||
- Repo:
|
||||
- abbr: GH
|
||||
href: "https://lab2025.duckdns.org/git/"
|
||||
- Public site:
|
||||
- abbr: HL
|
||||
href: "https://lab2025.duckdns.org"
|
||||
|
||||
- Runbooks:
|
||||
- Edge failures:
|
||||
- abbr: ED
|
||||
href: https://demos.lab2025.duckdns.org/homelab-catalog/
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
- Public:
|
||||
- Homepage:
|
||||
href: "https://homepage.lab2025.duckdns.org/"
|
||||
description: "Generated homelab operations dashboard"
|
||||
icon: "homepage.png"
|
||||
- Website:
|
||||
href: "https://lab2025.duckdns.org/"
|
||||
description: "Public portfolio website"
|
||||
icon: "mdi-web"
|
||||
- Demo Apps:
|
||||
href: "https://demos.lab2025.duckdns.org/"
|
||||
description: "Static browser-side demo catalog"
|
||||
icon: "mdi-test-tube"
|
||||
- Heimdall:
|
||||
href: "https://heimdall.lab2025.duckdns.org/"
|
||||
description: "Homelab service dashboard"
|
||||
icon: "heimdall.png"
|
||||
- Service Catalog:
|
||||
href: "https://demos.lab2025.duckdns.org/homelab-catalog/"
|
||||
description: "Generated host, service, route, and runbook map from homelab.yml"
|
||||
icon: "mdi-map"
|
||||
|
||||
- Platform:
|
||||
- Grafana:
|
||||
href: "https://grafana.lab2025.duckdns.org/"
|
||||
description: "Monitoring dashboards"
|
||||
icon: "grafana.png"
|
||||
- Prometheus:
|
||||
href: "https://prometheus.lab2025.duckdns.org/"
|
||||
description: "Prometheus query UI"
|
||||
icon: "prometheus.png"
|
||||
- Alertmanager:
|
||||
href: "https://alertmanager.lab2025.duckdns.org/"
|
||||
description: "Alert routing and silences"
|
||||
icon: "prometheus.png"
|
||||
- Argo CD:
|
||||
href: "https://argocd.lab2025.duckdns.org/"
|
||||
description: "GitOps application sync status"
|
||||
icon: "argocd.png"
|
||||
- Provisioning PXE:
|
||||
href: "http://192.168.100.73:8088/"
|
||||
description: "PXE, preseed, and worker provisioning HTTP files"
|
||||
icon: "mdi-lan-connect"
|
||||
- PXE Rescue:
|
||||
href: "http://192.168.100.73:8088/rescue/"
|
||||
description: "Browser rescue toolkit for manual repair paths"
|
||||
icon: "mdi-lifebuoy"
|
||||
- Gitea:
|
||||
href: "https://lab2025.duckdns.org/git/"
|
||||
description: "External Git service on the Debian host"
|
||||
icon: "gitea.png"
|
||||
- Container Registry:
|
||||
href: "http://192.168.100.73:30500/v2/_catalog"
|
||||
description: "Local image registry catalog endpoint"
|
||||
icon: "docker.png"
|
||||
|
||||
- Infrastructure:
|
||||
- Pi-hole:
|
||||
href: "http://192.168.100.89:8081/admin/"
|
||||
description: "LAN DNS and ad blocking on the Raspberry Pi"
|
||||
icon: "pi-hole.png"
|
||||
- Uptime Kuma:
|
||||
href: "http://192.168.100.89:3001/"
|
||||
description: "Service uptime checks on the Raspberry Pi"
|
||||
icon: "uptime-kuma.png"
|
||||
|
||||
- Devices:
|
||||
- Debian Laptop:
|
||||
href: "http://192.168.100.73:8088/"
|
||||
description: "Control plane, Docker host, Gitea, and provisioning server. Tailscale: 100.85.138.30"
|
||||
icon: "debian.png"
|
||||
ping: "192.168.100.73"
|
||||
- OCI Edge Server:
|
||||
href: "https://lab2025.duckdns.org/edge-health"
|
||||
description: "Public Nginx/HAProxy/Varnish/Squid edge. Public: 132.145.170.74; Tailscale: 100.118.255.19"
|
||||
icon: "nginx.png"
|
||||
ping: "132.145.170.74"
|
||||
- Pimox Hypervisor:
|
||||
href: "https://192.168.100.80:8006/"
|
||||
description: "Orange Pi 5 Pimox host for Kubernetes worker VMs"
|
||||
icon: "proxmox.png"
|
||||
ping: "192.168.100.80"
|
||||
- pimox-worker-01:
|
||||
href: "ssh://pimox-worker-01"
|
||||
description: "Pimox Kubernetes worker VMID 9010"
|
||||
icon: "kubernetes.png"
|
||||
ping: "pimox-worker-01"
|
||||
- pimox-worker-02:
|
||||
href: "ssh://pimox-worker-02"
|
||||
description: "Pimox Kubernetes worker VMID 9011"
|
||||
icon: "kubernetes.png"
|
||||
ping: "pimox-worker-02"
|
||||
|
||||
- Media:
|
||||
- Prowlarr:
|
||||
href: "http://192.168.100.73:9696/"
|
||||
description: "Indexer management for the media automation stack"
|
||||
icon: "prowlarr.png"
|
||||
- Sonarr:
|
||||
href: "http://192.168.100.73:8989/"
|
||||
description: "TV library automation"
|
||||
icon: "sonarr.png"
|
||||
- Radarr:
|
||||
href: "http://192.168.100.73:7878/"
|
||||
description: "Movie library automation"
|
||||
icon: "radarr.png"
|
||||
- qBittorrent:
|
||||
href: "http://192.168.100.73:8080/"
|
||||
description: "Torrent download client"
|
||||
icon: "qbittorrent.png"
|
||||
- Kapowarr:
|
||||
href: "http://192.168.100.73:5656/"
|
||||
description: "Comics library automation"
|
||||
icon: "mdi-book-open-page-variant"
|
||||
- Suwayomi:
|
||||
href: "http://192.168.100.73:4567/"
|
||||
description: "Manga server and scraper engine"
|
||||
icon: "mdi-book-open-variant"
|
||||
- Maintainerr:
|
||||
href: "http://192.168.100.73:6246/"
|
||||
description: "Media list maintenance automation"
|
||||
icon: "maintainerr.png"
|
||||
- FlareSolverr:
|
||||
href: "http://192.168.100.73:8191/"
|
||||
description: "Browser challenge solver service for ARR automation"
|
||||
icon: "mdi-cloud-refresh"
|
||||
- Jellyfin:
|
||||
href: "http://192.168.100.73:8096/"
|
||||
description: "Media streaming server"
|
||||
icon: "jellyfin.png"
|
||||
|
||||
- Communication:
|
||||
- Matrix:
|
||||
href: "https://matrix.lab2025.duckdns.org/"
|
||||
description: "Matrix Synapse homeserver"
|
||||
icon: "matrix.png"
|
||||
- Element:
|
||||
href: "https://element.lab2025.duckdns.org/"
|
||||
description: "Matrix web client"
|
||||
icon: "element.png"
|
||||
|
||||
- Automation:
|
||||
- n8n:
|
||||
href: "https://n8n.lab2025.duckdns.org/"
|
||||
description: "Workflow automation for translation jobs and homelab tasks"
|
||||
icon: "n8n.png"
|
||||
|
||||
- Labs:
|
||||
- Blockchain Explorer:
|
||||
href: "http://192.168.100.73:8089/"
|
||||
description: "Optional local Ethereum devnet explorer"
|
||||
icon: "mdi-cube-outline"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
title: "Homelab"
|
||||
theme: dark
|
||||
color: slate
|
||||
layout:
|
||||
Public:
|
||||
style: row
|
||||
columns: 4
|
||||
Platform:
|
||||
style: row
|
||||
columns: 4
|
||||
Infrastructure:
|
||||
style: row
|
||||
columns: 4
|
||||
Devices:
|
||||
style: row
|
||||
columns: 4
|
||||
Media:
|
||||
style: row
|
||||
columns: 4
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
- datetime:
|
||||
text_size: xl
|
||||
format:
|
||||
dateStyle: long
|
||||
timeStyle: short
|
||||
- resources:
|
||||
cpu: true
|
||||
memory: true
|
||||
disk: /
|
||||
|
|
@ -20,6 +20,13 @@
|
|||
"colour": "#7c3aed",
|
||||
"class": "Heimdall"
|
||||
},
|
||||
{
|
||||
"title": "Homepage",
|
||||
"url": "https://homepage.lab2025.duckdns.org/",
|
||||
"description": "Generated homelab operations dashboard",
|
||||
"colour": "#0284c7",
|
||||
"class": "Homepage"
|
||||
},
|
||||
{
|
||||
"title": "Matrix",
|
||||
"url": "https://matrix.lab2025.duckdns.org/",
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ mapping = {
|
|||
"services.heimdall.install_dir": "LAB_HEIMDALL_INSTALL_DIR",
|
||||
"services.heimdall.http_port": "LAB_HEIMDALL_HTTP_PORT",
|
||||
"services.heimdall.public_url": "LAB_HEIMDALL_PUBLIC_URL",
|
||||
"services.homepage.http_port": "LAB_HOMEPAGE_HTTP_PORT",
|
||||
"services.homepage.public_url": "LAB_HOMEPAGE_PUBLIC_URL",
|
||||
"services.local_registry.endpoint": "LAB_REGISTRY_ENDPOINT",
|
||||
"services.ollama.bind_address": "LAB_OLLAMA_BIND_ADDRESS",
|
||||
"services.ollama.models_dir": "LAB_OLLAMA_MODELS_DIR",
|
||||
|
|
@ -179,6 +181,8 @@ export_homelab_inventory_tf_vars() {
|
|||
export_if_unset TF_VAR_gitea_backend_port "${LAB_GITEA_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_heimdall_backend_host "${LAB_HEIMDALL_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_heimdall_backend_port "${LAB_HEIMDALL_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_homepage_backend_host "${LAB_HOMEPAGE_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_homepage_backend_port "${LAB_HOMEPAGE_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_gitops_repo_url "${LAB_GITOPS_REPO_URL:-}"
|
||||
export_if_unset TF_VAR_worker_tailscale_enabled "${LAB_PIMOX_WORKER_TAILSCALE_ENABLED:-}"
|
||||
export_if_unset TF_VAR_worker_tailscale_accept_routes "${LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES:-}"
|
||||
|
|
|
|||
|
|
@ -3877,9 +3877,16 @@ deploy_heimdall() {
|
|||
local container_name="${HEIMDALL_CONTAINER_NAME:-homelab-heimdall}"
|
||||
local seeder_container_name="${HEIMDALL_SEEDER_CONTAINER_NAME:-homelab-heimdall-link-seeder}"
|
||||
local network="${HEIMDALL_NETWORK:-homelab-heimdall}"
|
||||
local homepage_image="${HOMEPAGE_IMAGE:-ghcr.io/gethomepage/homepage:v1.5.0}"
|
||||
local homepage_container_name="${HOMEPAGE_CONTAINER_NAME:-homelab-homepage}"
|
||||
local homepage_http_port="${LAB_HOMEPAGE_HTTP_PORT:-8083}"
|
||||
local homepage_bind_ip="${LAB_HOMEPAGE_BIND_IP:-0.0.0.0}"
|
||||
local homepage_public_url="${LAB_HOMEPAGE_PUBLIC_URL:-https://homepage.${LAB_DOMAIN:-lab2025.duckdns.org}/}"
|
||||
local homepage_config_dir="${LAB_HOMEPAGE_CONFIG_DIR:-${install_dir}/homepage/config}"
|
||||
local install_docker="${LAB_HEIMDALL_INSTALL_DOCKER:-false}"
|
||||
local source_dir="${REPO_ROOT}/infra/heimdall"
|
||||
local link_generator="${REPO_ROOT}/scripts/generate-heimdall-links"
|
||||
local homepage_generator="${REPO_ROOT}/scripts/generate-homepage-config"
|
||||
local elapsed=0
|
||||
local value_name
|
||||
local value
|
||||
|
|
@ -3890,7 +3897,7 @@ deploy_heimdall() {
|
|||
return 0
|
||||
fi
|
||||
|
||||
for value_name in install_dir data_dir config_dir http_port bind_ip public_url image container_name seeder_container_name network install_docker; do
|
||||
for value_name in install_dir data_dir config_dir http_port bind_ip public_url image container_name seeder_container_name network homepage_image homepage_container_name homepage_http_port homepage_bind_ip homepage_public_url homepage_config_dir install_docker; do
|
||||
value="${!value_name}"
|
||||
if [[ "${value}" == *$'\n'* ]]; then
|
||||
echo "${value_name} cannot contain a newline." >&2
|
||||
|
|
@ -3901,8 +3908,11 @@ deploy_heimdall() {
|
|||
if [[ -x "${link_generator}" ]]; then
|
||||
"${link_generator}"
|
||||
fi
|
||||
if [[ -x "${homepage_generator}" ]]; then
|
||||
"${homepage_generator}"
|
||||
fi
|
||||
|
||||
if [[ ! -s "${source_dir}/docker-compose.yml" || ! -s "${source_dir}/links.json" || ! -s "${source_dir}/seed-heimdall.py" ]]; then
|
||||
if [[ ! -s "${source_dir}/docker-compose.yml" || ! -s "${source_dir}/links.json" || ! -s "${source_dir}/seed-heimdall.py" || ! -s "${source_dir}/homepage/services.yaml" ]]; then
|
||||
echo "Missing Heimdall source files in ${source_dir}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -3912,10 +3922,14 @@ deploy_heimdall() {
|
|||
ensure_local_docker_compose "HEIMDALL" "${install_docker}"
|
||||
repair_local_docker_iptables
|
||||
|
||||
sudo mkdir -p "${install_dir}" "${config_dir}"
|
||||
sudo mkdir -p "${install_dir}" "${config_dir}" "${homepage_config_dir}"
|
||||
sudo cp "${source_dir}/docker-compose.yml" "${install_dir}/docker-compose.yml"
|
||||
sudo cp "${source_dir}/links.json" "${install_dir}/links.json"
|
||||
sudo cp "${source_dir}/seed-heimdall.py" "${install_dir}/seed-heimdall.py"
|
||||
sudo cp "${source_dir}/homepage/services.yaml" "${homepage_config_dir}/services.yaml"
|
||||
sudo cp "${source_dir}/homepage/bookmarks.yaml" "${homepage_config_dir}/bookmarks.yaml"
|
||||
sudo cp "${source_dir}/homepage/settings.yaml" "${homepage_config_dir}/settings.yaml"
|
||||
sudo cp "${source_dir}/homepage/widgets.yaml" "${homepage_config_dir}/widgets.yaml"
|
||||
sudo chown -R 1000:1000 "${data_dir}"
|
||||
sudo tee "${install_dir}/.env" >/dev/null <<ENV_EOT
|
||||
HEIMDALL_IMAGE=${image}
|
||||
|
|
@ -3928,6 +3942,15 @@ HEIMDALL_CONFIG_DIR=${config_dir}
|
|||
HEIMDALL_UID=1000
|
||||
HEIMDALL_GID=1000
|
||||
HEIMDALL_NETWORK=${network}
|
||||
HOMEPAGE_IMAGE=${homepage_image}
|
||||
HOMEPAGE_CONTAINER_NAME=${homepage_container_name}
|
||||
HOMEPAGE_HTTP_PORT=${homepage_http_port}
|
||||
HOMEPAGE_BIND_IP=${homepage_bind_ip}
|
||||
HOMEPAGE_PUBLIC_URL=${homepage_public_url%/}
|
||||
HOMEPAGE_CONFIG_DIR=${homepage_config_dir}
|
||||
HOMEPAGE_ALLOWED_HOSTS=homepage.${LAB_DOMAIN:-lab2025.duckdns.org},127.0.0.1:${homepage_http_port},localhost:${homepage_http_port}
|
||||
HOMEPAGE_UID=1000
|
||||
HOMEPAGE_GID=1000
|
||||
TZ=America/Mexico_City
|
||||
ENV_EOT
|
||||
|
||||
|
|
@ -3948,7 +3971,19 @@ ENV_EOT
|
|||
elapsed=$((elapsed + 5))
|
||||
done
|
||||
|
||||
elapsed=0
|
||||
until curl -fsS --connect-timeout 5 "http://127.0.0.1:${homepage_http_port}/" >/dev/null; do
|
||||
if ((elapsed >= 360)); then
|
||||
echo "Timed out waiting for Homepage on http://127.0.0.1:${homepage_http_port}/" >&2
|
||||
(cd "${install_dir}" && sudo docker compose ps && sudo docker compose logs --tail=120) >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
elapsed=$((elapsed + 5))
|
||||
done
|
||||
|
||||
echo "Heimdall is reachable at http://127.0.0.1:${http_port}/ and ${public_url%/}/."
|
||||
echo "Homepage is reachable at http://127.0.0.1:${homepage_http_port}/ and ${homepage_public_url%/}/."
|
||||
}
|
||||
|
||||
deploy_matrix() {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ HOST_METADATA = {
|
|||
"lab2025": ("Website", "Public portfolio website", "#0f766e", "Website"),
|
||||
"demos": ("Demo Apps", "Static browser-side demo catalog", "#2563eb", "Demos"),
|
||||
"heimdall": ("Heimdall", "Homelab service dashboard", "#7c3aed", "Heimdall"),
|
||||
"homepage": ("Homepage", "Generated homelab operations dashboard", "#0284c7", "Homepage"),
|
||||
"matrix": ("Matrix", "Matrix Synapse homeserver", "#0f172a", "Matrix"),
|
||||
"element": ("Element", "Matrix web client", "#0ea5e9", "Element"),
|
||||
"grafana": ("Grafana", "Monitoring dashboards", "#f97316", "Grafana"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,377 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Generate Homepage dashboard config from homelab inventory and Heimdall links."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
REPO_ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
INVENTORY = REPO_ROOT / "homelab.yml"
|
||||
HEIMDALL_LINKS = REPO_ROOT / "infra" / "heimdall" / "links.json"
|
||||
OUTPUT_DIR = REPO_ROOT / "infra" / "heimdall" / "homepage"
|
||||
|
||||
SERVICE_GROUPS = {
|
||||
"Website": "Public",
|
||||
"Demo Apps": "Public",
|
||||
"Homepage": "Public",
|
||||
"Heimdall": "Public",
|
||||
"Service Catalog": "Public",
|
||||
"Gitea": "Platform",
|
||||
"Argo CD": "Platform",
|
||||
"Grafana": "Platform",
|
||||
"Prometheus": "Platform",
|
||||
"Alertmanager": "Platform",
|
||||
"Provisioning PXE": "Platform",
|
||||
"PXE Rescue": "Platform",
|
||||
"Container Registry": "Platform",
|
||||
"Matrix": "Communication",
|
||||
"Element": "Communication",
|
||||
"n8n": "Automation",
|
||||
"Pi-hole": "Infrastructure",
|
||||
"Uptime Kuma": "Infrastructure",
|
||||
"Blockchain Explorer": "Labs",
|
||||
"Prowlarr": "Media",
|
||||
"Sonarr": "Media",
|
||||
"Radarr": "Media",
|
||||
"qBittorrent": "Media",
|
||||
"Kapowarr": "Media",
|
||||
"Suwayomi": "Media",
|
||||
"Maintainerr": "Media",
|
||||
"FlareSolverr": "Media",
|
||||
"Jellyfin": "Media",
|
||||
}
|
||||
|
||||
GROUP_ORDER = (
|
||||
"Public",
|
||||
"Platform",
|
||||
"Infrastructure",
|
||||
"Devices",
|
||||
"Media",
|
||||
"Communication",
|
||||
"Automation",
|
||||
"Labs",
|
||||
"Other",
|
||||
)
|
||||
|
||||
ICON_MAP = {
|
||||
"Website": "mdi-web",
|
||||
"Demo Apps": "mdi-test-tube",
|
||||
"Homepage": "homepage.png",
|
||||
"Heimdall": "heimdall.png",
|
||||
"Service Catalog": "mdi-map",
|
||||
"Gitea": "gitea.png",
|
||||
"Argo CD": "argocd.png",
|
||||
"Grafana": "grafana.png",
|
||||
"Prometheus": "prometheus.png",
|
||||
"Alertmanager": "prometheus.png",
|
||||
"Provisioning PXE": "mdi-lan-connect",
|
||||
"PXE Rescue": "mdi-lifebuoy",
|
||||
"Container Registry": "docker.png",
|
||||
"Pi-hole": "pi-hole.png",
|
||||
"Uptime Kuma": "uptime-kuma.png",
|
||||
"Matrix": "matrix.png",
|
||||
"Element": "element.png",
|
||||
"n8n": "n8n.png",
|
||||
"Prowlarr": "prowlarr.png",
|
||||
"Sonarr": "sonarr.png",
|
||||
"Radarr": "radarr.png",
|
||||
"qBittorrent": "qbittorrent.png",
|
||||
"Kapowarr": "mdi-book-open-page-variant",
|
||||
"Suwayomi": "mdi-book-open-variant",
|
||||
"Maintainerr": "maintainerr.png",
|
||||
"FlareSolverr": "mdi-cloud-refresh",
|
||||
"Jellyfin": "jellyfin.png",
|
||||
"Blockchain Explorer": "mdi-cube-outline",
|
||||
}
|
||||
|
||||
|
||||
def parse_inventory(path: pathlib.Path) -> dict[str, Any]:
|
||||
values: dict[str, Any] = {}
|
||||
stack: list[tuple[int, str]] = []
|
||||
current_list_path: str | None = None
|
||||
pattern = re.compile(r"^(\s*)([A-Za-z_][A-Za-z0-9_]*):(?:\s*(.*?))?\s*$")
|
||||
|
||||
with path.open(encoding="utf-8") as handle:
|
||||
for raw_line in handle:
|
||||
stripped = raw_line.strip()
|
||||
if not stripped or stripped.startswith("#"):
|
||||
continue
|
||||
if stripped.startswith("- "):
|
||||
if current_list_path:
|
||||
values.setdefault(current_list_path, [])
|
||||
values[current_list_path].append(clean_value(stripped[2:]))
|
||||
continue
|
||||
|
||||
match = pattern.match(raw_line.rstrip("\n"))
|
||||
if not match:
|
||||
current_list_path = None
|
||||
continue
|
||||
|
||||
indent = len(match.group(1))
|
||||
key = match.group(2)
|
||||
value = (match.group(3) or "").strip()
|
||||
while stack and stack[-1][0] >= indent:
|
||||
stack.pop()
|
||||
path_key = ".".join([item[1] for item in stack] + [key])
|
||||
if value == "":
|
||||
stack.append((indent, key))
|
||||
current_list_path = path_key
|
||||
continue
|
||||
values[path_key] = clean_value(value)
|
||||
current_list_path = None
|
||||
return values
|
||||
|
||||
|
||||
def clean_value(value: str) -> str:
|
||||
if " #" in value:
|
||||
value = value.split(" #", 1)[0]
|
||||
return value.strip().strip('"\'')
|
||||
|
||||
|
||||
def value(values: dict[str, Any], path: str, default: str = "") -> str:
|
||||
raw_value = values.get(path, default)
|
||||
if isinstance(raw_value, list):
|
||||
return ", ".join(str(item) for item in raw_value)
|
||||
return str(raw_value)
|
||||
|
||||
|
||||
def yaml_scalar(text: str) -> str:
|
||||
return json.dumps(str(text))
|
||||
|
||||
|
||||
def service_item(name: str, href: str, description: str, icon: str = "", ping: str = "") -> dict[str, str]:
|
||||
item = {
|
||||
"name": name,
|
||||
"href": href,
|
||||
"description": description,
|
||||
}
|
||||
if icon:
|
||||
item["icon"] = icon
|
||||
if ping:
|
||||
item["ping"] = ping
|
||||
return item
|
||||
|
||||
|
||||
def load_heimdall_links() -> list[dict[str, str]]:
|
||||
if not HEIMDALL_LINKS.exists():
|
||||
return []
|
||||
with HEIMDALL_LINKS.open(encoding="utf-8") as handle:
|
||||
return json.load(handle)
|
||||
|
||||
|
||||
def homepage_link(values: dict[str, Any]) -> dict[str, str]:
|
||||
public_url = value(values, "services.homepage.public_url", f"https://homepage.{value(values, 'domain.base')}/")
|
||||
return {
|
||||
"title": "Homepage",
|
||||
"url": public_url,
|
||||
"description": "Generated homelab operations dashboard",
|
||||
"class": "Homepage",
|
||||
}
|
||||
|
||||
|
||||
def generated_services(values: dict[str, Any]) -> dict[str, list[dict[str, str]]]:
|
||||
groups = {group: [] for group in GROUP_ORDER}
|
||||
links = [homepage_link(values), *load_heimdall_links()]
|
||||
|
||||
seen: set[str] = set()
|
||||
for link in links:
|
||||
title = link["title"].strip()
|
||||
if not title or title.lower() in seen:
|
||||
continue
|
||||
seen.add(title.lower())
|
||||
group = SERVICE_GROUPS.get(title, "Other")
|
||||
groups[group].append(
|
||||
service_item(
|
||||
title,
|
||||
link["url"],
|
||||
link.get("description", ""),
|
||||
ICON_MAP.get(title, ""),
|
||||
)
|
||||
)
|
||||
|
||||
for device in device_services(values):
|
||||
groups["Devices"].append(device)
|
||||
|
||||
return {group: items for group, items in groups.items() if items}
|
||||
|
||||
|
||||
def device_services(values: dict[str, Any]) -> list[dict[str, str]]:
|
||||
debian_ip = value(values, "hosts.debian.lan_ip")
|
||||
debian_ts = value(values, "hosts.debian.tailscale_ip")
|
||||
edge_ip = value(values, "hosts.oci_edge.public_ip")
|
||||
edge_ts = value(values, "hosts.oci_edge.tailscale_ip")
|
||||
pimox_ip = value(values, "hosts.opi5_pimox.lan_ip")
|
||||
worker_count = int(value(values, "pimox.default_worker_count", "0") or "0")
|
||||
worker_prefix = value(values, "pimox.worker_name_prefix", "pimox-worker")
|
||||
worker_base_vmid = int(value(values, "pimox.worker_base_vmid", "9010") or "9010")
|
||||
|
||||
devices = [
|
||||
service_item(
|
||||
"Debian Laptop",
|
||||
f"http://{debian_ip}:8088/",
|
||||
f"Control plane, Docker host, Gitea, and provisioning server. Tailscale: {debian_ts}",
|
||||
"debian.png",
|
||||
debian_ip,
|
||||
),
|
||||
service_item(
|
||||
"OCI Edge Server",
|
||||
f"https://{value(values, 'domain.base')}/edge-health",
|
||||
f"Public Nginx/HAProxy/Varnish/Squid edge. Public: {edge_ip}; Tailscale: {edge_ts}",
|
||||
"nginx.png",
|
||||
edge_ip,
|
||||
),
|
||||
service_item(
|
||||
"Pimox Hypervisor",
|
||||
f"https://{pimox_ip}:8006/",
|
||||
"Orange Pi 5 Pimox host for Kubernetes worker VMs",
|
||||
"proxmox.png",
|
||||
pimox_ip,
|
||||
),
|
||||
]
|
||||
|
||||
for index in range(1, worker_count + 1):
|
||||
worker_name = f"{worker_prefix}-{index:02d}"
|
||||
vmid = worker_base_vmid + index - 1
|
||||
devices.append(
|
||||
service_item(
|
||||
worker_name,
|
||||
f"ssh://{worker_name}",
|
||||
f"Pimox Kubernetes worker VMID {vmid}",
|
||||
"kubernetes.png",
|
||||
worker_name,
|
||||
)
|
||||
)
|
||||
return devices
|
||||
|
||||
|
||||
def render_services(groups: dict[str, list[dict[str, str]]]) -> str:
|
||||
lines: list[str] = []
|
||||
for group, items in groups.items():
|
||||
lines.append(f"- {group}:")
|
||||
for item in items:
|
||||
lines.append(f" - {item['name']}:")
|
||||
lines.append(f" href: {yaml_scalar(item['href'])}")
|
||||
lines.append(f" description: {yaml_scalar(item['description'])}")
|
||||
if item.get("icon"):
|
||||
lines.append(f" icon: {yaml_scalar(item['icon'])}")
|
||||
if item.get("ping"):
|
||||
lines.append(f" ping: {yaml_scalar(item['ping'])}")
|
||||
lines.append("")
|
||||
return "\n".join(lines).rstrip() + "\n"
|
||||
|
||||
|
||||
def render_bookmarks(values: dict[str, Any]) -> str:
|
||||
repo_url = value(values, "services.gitea.root_url", value(values, "domain.gitea_url"))
|
||||
public_url = value(values, "domain.public_url")
|
||||
return "\n".join(
|
||||
[
|
||||
"- Homelab:",
|
||||
" - Repo:",
|
||||
f" - abbr: GH",
|
||||
f" href: {yaml_scalar(repo_url)}",
|
||||
" - Public site:",
|
||||
f" - abbr: HL",
|
||||
f" href: {yaml_scalar(public_url)}",
|
||||
"",
|
||||
"- Runbooks:",
|
||||
" - Edge failures:",
|
||||
" - abbr: ED",
|
||||
" href: https://demos.lab2025.duckdns.org/homelab-catalog/",
|
||||
"",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def render_settings(values: dict[str, Any]) -> str:
|
||||
return "\n".join(
|
||||
[
|
||||
f"title: {yaml_scalar('Homelab')}",
|
||||
"theme: dark",
|
||||
"color: slate",
|
||||
"layout:",
|
||||
" Public:",
|
||||
" style: row",
|
||||
" columns: 4",
|
||||
" Platform:",
|
||||
" style: row",
|
||||
" columns: 4",
|
||||
" Infrastructure:",
|
||||
" style: row",
|
||||
" columns: 4",
|
||||
" Devices:",
|
||||
" style: row",
|
||||
" columns: 4",
|
||||
" Media:",
|
||||
" style: row",
|
||||
" columns: 4",
|
||||
"",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def render_widgets(values: dict[str, Any]) -> str:
|
||||
return "\n".join(
|
||||
[
|
||||
"- datetime:",
|
||||
" text_size: xl",
|
||||
" format:",
|
||||
" dateStyle: long",
|
||||
" timeStyle: short",
|
||||
"- resources:",
|
||||
" cpu: true",
|
||||
" memory: true",
|
||||
" disk: /",
|
||||
"",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def write_if_changed(path: pathlib.Path, content: str) -> bool:
|
||||
if path.exists() and path.read_text(encoding="utf-8") == content:
|
||||
return False
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(content, encoding="utf-8")
|
||||
return True
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--output-dir", type=pathlib.Path, default=OUTPUT_DIR)
|
||||
parser.add_argument("--check", action="store_true", help="fail if generated files are stale")
|
||||
args = parser.parse_args()
|
||||
|
||||
values = parse_inventory(INVENTORY)
|
||||
outputs = {
|
||||
"services.yaml": render_services(generated_services(values)),
|
||||
"bookmarks.yaml": render_bookmarks(values),
|
||||
"settings.yaml": render_settings(values),
|
||||
"widgets.yaml": render_widgets(values),
|
||||
}
|
||||
|
||||
stale = []
|
||||
for name, content in outputs.items():
|
||||
path = args.output_dir / name
|
||||
if args.check:
|
||||
current = path.read_text(encoding="utf-8") if path.exists() else ""
|
||||
if current != content:
|
||||
stale.append(str(path.relative_to(REPO_ROOT)))
|
||||
else:
|
||||
write_if_changed(path, content)
|
||||
|
||||
if stale:
|
||||
print("Homepage config is stale; run scripts/generate-homepage-config:")
|
||||
for path in stale:
|
||||
print(f" {path}")
|
||||
return 1
|
||||
|
||||
if not args.check:
|
||||
print(f"Generated Homepage config in {args.output_dir.relative_to(REPO_ROOT)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Reference in New Issue