feat: add selectable Pimox cluster profile

This commit is contained in:
juvenal.diaz 2026-10-01 08:27:42 -06:00
parent dea1bc7521
commit cbe2ea88cd
5 changed files with 84 additions and 10 deletions

View File

@ -59,6 +59,32 @@ cluster:
repo_url: ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git repo_url: ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git
platform: platform:
calico_operator_node_name: debian calico_operator_node_name: debian
pimox:
control_plane:
node_name: pimox-cp-01
lan_ip: 192.168.100.65
user: jv
kubeconfig: /home/jv/.kube/pimox-config
kubeconfig_owner: jv:jv
registry:
endpoint: 192.168.100.73:30500
provisioning:
host: 192.168.100.73
user: jv
http:
host: 192.168.100.73
gitops:
repo_url: ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git
platform:
calico_operator_node_name: pimox-cp-01
pimox:
host: 192.168.100.80
user: jv
bridge: vmbr0
storage: opi5_ssd
control_plane_vmid: 9001
worker_count: 2
worker_static_ips: 192.168.100.66 192.168.100.67
hosts: hosts:
debian: debian:

View File

@ -44,6 +44,7 @@ Base, Inventory, And Planning
help | -h | --help Show this grouped help. help | -h | --help Show this grouped help.
validate Run repo validation checks. validate Run repo validation checks.
inventory-check Validate the canonical homelab inventory. inventory-check Validate the canonical homelab inventory.
cluster-profile Print the resolved active cluster profile.
preflight Run non-mutating infrastructure preflight checks. preflight Run non-mutating infrastructure preflight checks.
doctor-preapply Run deeper pre-apply safety checks. doctor-preapply Run deeper pre-apply safety checks.
plan [all|provisioning|cluster|platform|apps|edge] plan [all|provisioning|cluster|platform|apps|edge]
@ -200,6 +201,9 @@ case "${1:-}" in
plan) plan)
plan_homelab "${2:-all}" plan_homelab "${2:-all}"
;; ;;
cluster-profile)
cluster_profile_report
;;
rebuild-cluster) rebuild-cluster)
record_change_journal "rebuild-cluster" "$@" record_change_journal "rebuild-cluster" "$@"
rebuild_cluster rebuild_cluster

View File

@ -33,6 +33,28 @@ plan_homelab() {
done done
} }
cluster_profile_report() {
cat <<EOF
Active cluster profile: ${LAB_CLUSTER_PROFILE:-debian}
Control plane node: ${LAB_CLUSTER_CONTROL_PLANE_NODE_NAME:-debian}
Control plane LAN IP: ${LAB_CLUSTER_CONTROL_PLANE_LAN_IP:-${LAB_DEBIAN_LAN_IP:-}}
Control plane SSH user: ${LAB_CLUSTER_CONTROL_PLANE_USER:-${LAB_DEBIAN_USER:-}}
Kubeconfig path: ${LAB_KUBECONFIG_PATH:-${KUBECONFIG_PATH:-}}
Kubeconfig owner: ${LAB_CLUSTER_KUBECONFIG_OWNER:-}
Registry endpoint: ${LAB_REGISTRY_ENDPOINT:-}
Provisioning host: ${LAB_CLUSTER_PROVISIONING_HOST:-${LAB_DEBIAN_LAN_IP:-}}
Provisioning user: ${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}
GitOps repo URL: ${LAB_GITOPS_REPO_URL:-}
Calico operator node: ${LAB_CALICO_OPERATOR_NODE_NAME:-${LAB_CLUSTER_CONTROL_PLANE_NODE_NAME:-}}
Pimox host: ${LAB_CLUSTER_PIMOX_USER:-${LAB_PIMOX_USER:-}}@${LAB_CLUSTER_PIMOX_HOST:-${LAB_PIMOX_HOST:-}}
Pimox bridge: ${LAB_CLUSTER_PIMOX_BRIDGE:-${LAB_PIMOX_BRIDGE:-}}
Pimox storage: ${LAB_CLUSTER_PIMOX_STORAGE:-${LAB_PIMOX_WORKER_STORAGE:-}}
Pimox control-plane VMID: ${LAB_CLUSTER_PIMOX_CONTROL_PLANE_VMID:-}
Pimox worker count: ${LAB_CLUSTER_PIMOX_WORKER_COUNT:-${LAB_PIMOX_WORKER_COUNT:-}}
Pimox worker static IPs: ${LAB_CLUSTER_PIMOX_WORKER_STATIC_IPS:-${LAB_PIMOX_WORKER_STATIC_IPS:-}}
EOF
}
rebuild_cluster() { rebuild_cluster() {
require_debian_server "rebuild-cluster" require_debian_server "rebuild-cluster"

View File

@ -11,6 +11,7 @@ load_homelab_inventory_defaults() {
rendered_defaults="$(python3 - "${inventory_file}" <<'PY' rendered_defaults="$(python3 - "${inventory_file}" <<'PY'
import re import re
import json import json
import os
import shlex import shlex
import sys import sys
@ -123,7 +124,7 @@ for path, env_name in mapping.items():
if value: if value:
print(f": ${{{env_name}:={shlex.quote(value)}}}") print(f": ${{{env_name}:={shlex.quote(value)}}}")
cluster_profile = values.get("cluster.active_profile") or "debian" cluster_profile = os.environ.get("LAB_CLUSTER_PROFILE") or values.get("cluster.active_profile") or "debian"
print(f": ${{LAB_CLUSTER_PROFILE:={shlex.quote(cluster_profile)}}}") print(f": ${{LAB_CLUSTER_PROFILE:={shlex.quote(cluster_profile)}}}")
profile_prefix = f"cluster.profiles.{cluster_profile}" profile_prefix = f"cluster.profiles.{cluster_profile}"
profile_mapping = { profile_mapping = {
@ -138,6 +139,13 @@ profile_mapping = {
"http.host": ("LAB_CLUSTER_HTTP_HOST", "hosts.debian.lan_ip"), "http.host": ("LAB_CLUSTER_HTTP_HOST", "hosts.debian.lan_ip"),
"gitops.repo_url": ("LAB_GITOPS_REPO_URL", "services.gitea.ssh_remote"), "gitops.repo_url": ("LAB_GITOPS_REPO_URL", "services.gitea.ssh_remote"),
"platform.calico_operator_node_name": ("LAB_CALICO_OPERATOR_NODE_NAME", None), "platform.calico_operator_node_name": ("LAB_CALICO_OPERATOR_NODE_NAME", None),
"pimox.host": ("LAB_CLUSTER_PIMOX_HOST", "hosts.opi5_pimox.lan_ip"),
"pimox.user": ("LAB_CLUSTER_PIMOX_USER", "hosts.opi5_pimox.user"),
"pimox.bridge": ("LAB_CLUSTER_PIMOX_BRIDGE", "hosts.opi5_pimox.bridge"),
"pimox.storage": ("LAB_CLUSTER_PIMOX_STORAGE", "hosts.opi5_pimox.worker_storage"),
"pimox.control_plane_vmid": ("LAB_CLUSTER_PIMOX_CONTROL_PLANE_VMID", None),
"pimox.worker_count": ("LAB_CLUSTER_PIMOX_WORKER_COUNT", "pimox.default_worker_count"),
"pimox.worker_static_ips": ("LAB_CLUSTER_PIMOX_WORKER_STATIC_IPS", None),
} }
for relative_path, (env_name, fallback_path) in profile_mapping.items(): for relative_path, (env_name, fallback_path) in profile_mapping.items():
value = values.get(f"{profile_prefix}.{relative_path}") value = values.get(f"{profile_prefix}.{relative_path}")
@ -200,10 +208,11 @@ export_homelab_inventory_tf_vars() {
export_if_unset TF_VAR_provisioning_host "${LAB_CLUSTER_PROVISIONING_HOST:-${LAB_DEBIAN_LAN_IP:-}}" export_if_unset TF_VAR_provisioning_host "${LAB_CLUSTER_PROVISIONING_HOST:-${LAB_DEBIAN_LAN_IP:-}}"
export_if_unset TF_VAR_provisioning_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}" export_if_unset TF_VAR_provisioning_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}"
export_if_unset TF_VAR_http_host "${LAB_CLUSTER_HTTP_HOST:-${LAB_CLUSTER_CONTROL_PLANE_LAN_IP:-${LAB_DEBIAN_LAN_IP:-}}}" export_if_unset TF_VAR_http_host "${LAB_CLUSTER_HTTP_HOST:-${LAB_CLUSTER_CONTROL_PLANE_LAN_IP:-${LAB_DEBIAN_LAN_IP:-}}}"
export_if_unset TF_VAR_pimox_host "${LAB_PIMOX_HOST:-}" export_if_unset TF_VAR_pimox_host "${LAB_CLUSTER_PIMOX_HOST:-${LAB_PIMOX_HOST:-}}"
export_if_unset TF_VAR_pimox_user "${LAB_PIMOX_USER:-}" export_if_unset TF_VAR_pimox_user "${LAB_CLUSTER_PIMOX_USER:-${LAB_PIMOX_USER:-}}"
export_if_unset TF_VAR_pimox_worker_storage "${LAB_PIMOX_WORKER_STORAGE:-}" export_if_unset TF_VAR_pimox_worker_storage "${LAB_CLUSTER_PIMOX_STORAGE:-${LAB_PIMOX_WORKER_STORAGE:-}}"
export_if_unset TF_VAR_pimox_template_bridge "${LAB_PIMOX_BRIDGE:-}" export_if_unset TF_VAR_pimox_template_bridge "${LAB_CLUSTER_PIMOX_BRIDGE:-${LAB_PIMOX_BRIDGE:-}}"
export_if_unset TF_VAR_pimox_template_vmid "${LAB_PIMOX_TEMPLATE_VMID:-}"
export_if_unset TF_VAR_pimox_template_build_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}" export_if_unset TF_VAR_pimox_template_build_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}"
export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}" export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}"
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}" export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
@ -231,6 +240,8 @@ export_homelab_inventory_tf_vars() {
export_if_unset TF_VAR_worker_tailscale_enabled "${LAB_PIMOX_WORKER_TAILSCALE_ENABLED:-}" 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:-}" export_if_unset TF_VAR_worker_tailscale_accept_routes "${LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES:-}"
export_if_unset TF_VAR_worker_tailscale_pod_egress_snat "${LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT:-}" export_if_unset TF_VAR_worker_tailscale_pod_egress_snat "${LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT:-}"
export_if_unset LAB_PIMOX_WORKER_COUNT "${LAB_CLUSTER_PIMOX_WORKER_COUNT:-}"
export_if_unset LAB_PIMOX_WORKER_STATIC_IPS "${LAB_CLUSTER_PIMOX_WORKER_STATIC_IPS:-}"
} }
sops_available() { sops_available() {

View File

@ -12,6 +12,7 @@ load_homelab_inventory_defaults() {
rendered_defaults="$(python3 - "${inventory_file}" <<'PY' rendered_defaults="$(python3 - "${inventory_file}" <<'PY'
import re import re
import json import json
import os
import shlex import shlex
import sys import sys
@ -124,7 +125,7 @@ for path, env_name in mapping.items():
if value: if value:
print(f": ${{{env_name}:={shlex.quote(value)}}}") print(f": ${{{env_name}:={shlex.quote(value)}}}")
cluster_profile = values.get("cluster.active_profile") or "debian" cluster_profile = os.environ.get("LAB_CLUSTER_PROFILE") or values.get("cluster.active_profile") or "debian"
print(f": ${{LAB_CLUSTER_PROFILE:={shlex.quote(cluster_profile)}}}") print(f": ${{LAB_CLUSTER_PROFILE:={shlex.quote(cluster_profile)}}}")
profile_prefix = f"cluster.profiles.{cluster_profile}" profile_prefix = f"cluster.profiles.{cluster_profile}"
profile_mapping = { profile_mapping = {
@ -139,6 +140,13 @@ profile_mapping = {
"http.host": ("LAB_CLUSTER_HTTP_HOST", "hosts.debian.lan_ip"), "http.host": ("LAB_CLUSTER_HTTP_HOST", "hosts.debian.lan_ip"),
"gitops.repo_url": ("LAB_GITOPS_REPO_URL", "services.gitea.ssh_remote"), "gitops.repo_url": ("LAB_GITOPS_REPO_URL", "services.gitea.ssh_remote"),
"platform.calico_operator_node_name": ("LAB_CALICO_OPERATOR_NODE_NAME", None), "platform.calico_operator_node_name": ("LAB_CALICO_OPERATOR_NODE_NAME", None),
"pimox.host": ("LAB_CLUSTER_PIMOX_HOST", "hosts.opi5_pimox.lan_ip"),
"pimox.user": ("LAB_CLUSTER_PIMOX_USER", "hosts.opi5_pimox.user"),
"pimox.bridge": ("LAB_CLUSTER_PIMOX_BRIDGE", "hosts.opi5_pimox.bridge"),
"pimox.storage": ("LAB_CLUSTER_PIMOX_STORAGE", "hosts.opi5_pimox.worker_storage"),
"pimox.control_plane_vmid": ("LAB_CLUSTER_PIMOX_CONTROL_PLANE_VMID", None),
"pimox.worker_count": ("LAB_CLUSTER_PIMOX_WORKER_COUNT", "pimox.default_worker_count"),
"pimox.worker_static_ips": ("LAB_CLUSTER_PIMOX_WORKER_STATIC_IPS", None),
} }
for relative_path, (env_name, fallback_path) in profile_mapping.items(): for relative_path, (env_name, fallback_path) in profile_mapping.items():
value = values.get(f"{profile_prefix}.{relative_path}") value = values.get(f"{profile_prefix}.{relative_path}")
@ -201,10 +209,11 @@ export_homelab_inventory_tf_vars() {
export_if_unset TF_VAR_provisioning_host "${LAB_CLUSTER_PROVISIONING_HOST:-${LAB_DEBIAN_LAN_IP:-}}" export_if_unset TF_VAR_provisioning_host "${LAB_CLUSTER_PROVISIONING_HOST:-${LAB_DEBIAN_LAN_IP:-}}"
export_if_unset TF_VAR_provisioning_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}" export_if_unset TF_VAR_provisioning_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}"
export_if_unset TF_VAR_http_host "${LAB_CLUSTER_HTTP_HOST:-${LAB_CLUSTER_CONTROL_PLANE_LAN_IP:-${LAB_DEBIAN_LAN_IP:-}}}" export_if_unset TF_VAR_http_host "${LAB_CLUSTER_HTTP_HOST:-${LAB_CLUSTER_CONTROL_PLANE_LAN_IP:-${LAB_DEBIAN_LAN_IP:-}}}"
export_if_unset TF_VAR_pimox_host "${LAB_PIMOX_HOST:-}" export_if_unset TF_VAR_pimox_host "${LAB_CLUSTER_PIMOX_HOST:-${LAB_PIMOX_HOST:-}}"
export_if_unset TF_VAR_pimox_user "${LAB_PIMOX_USER:-}" export_if_unset TF_VAR_pimox_user "${LAB_CLUSTER_PIMOX_USER:-${LAB_PIMOX_USER:-}}"
export_if_unset TF_VAR_pimox_worker_storage "${LAB_PIMOX_WORKER_STORAGE:-}" export_if_unset TF_VAR_pimox_worker_storage "${LAB_CLUSTER_PIMOX_STORAGE:-${LAB_PIMOX_WORKER_STORAGE:-}}"
export_if_unset TF_VAR_pimox_template_bridge "${LAB_PIMOX_BRIDGE:-}" export_if_unset TF_VAR_pimox_template_bridge "${LAB_CLUSTER_PIMOX_BRIDGE:-${LAB_PIMOX_BRIDGE:-}}"
export_if_unset TF_VAR_pimox_template_vmid "${LAB_PIMOX_TEMPLATE_VMID:-}"
export_if_unset TF_VAR_pimox_template_build_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}" export_if_unset TF_VAR_pimox_template_build_user "${LAB_CLUSTER_PROVISIONING_USER:-${LAB_DEBIAN_USER:-}}"
export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}" export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}"
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}" export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
@ -232,6 +241,8 @@ export_homelab_inventory_tf_vars() {
export_if_unset TF_VAR_worker_tailscale_enabled "${LAB_PIMOX_WORKER_TAILSCALE_ENABLED:-}" 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:-}" export_if_unset TF_VAR_worker_tailscale_accept_routes "${LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES:-}"
export_if_unset TF_VAR_worker_tailscale_pod_egress_snat "${LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT:-}" export_if_unset TF_VAR_worker_tailscale_pod_egress_snat "${LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT:-}"
export_if_unset LAB_PIMOX_WORKER_COUNT "${LAB_CLUSTER_PIMOX_WORKER_COUNT:-}"
export_if_unset LAB_PIMOX_WORKER_STATIC_IPS "${LAB_CLUSTER_PIMOX_WORKER_STATIC_IPS:-}"
} }
configure_platform_grafana_sso() { configure_platform_grafana_sso() {