diff --git a/apps/website/blog.php b/apps/website/blog.php index bd625c7..554e734 100644 --- a/apps/website/blog.php +++ b/apps/website/blog.php @@ -150,10 +150,6 @@ $stackSourceLinks = [ ['label' => 'jeannie worker storage guardrail', 'path' => 'jeannie'], ['label' => 'README Pimox defaults', 'path' => 'README.md'], ], - 'blog_stack_15' => [ - ['label' => 'jeannie OpenWrt pipeline', 'path' => 'jeannie'], - ['label' => 'README OpenWrt notes', 'path' => 'README.md'], - ], 'blog_stack_16' => [ ['label' => 'platform/main.tf', 'path' => 'bootstrap/platform/main.tf'], ['label' => 'README monitoring', 'path' => 'README.md'], diff --git a/apps/website/lang/en.php b/apps/website/lang/en.php index 5d1b1e9..42a9c65 100644 --- a/apps/website/lang/en.php +++ b/apps/website/lang/en.php @@ -152,7 +152,7 @@ return [ 'blog_q8' => 'So the lab can now build its own worker nodes?', 'blog_a8' => 'Yes, and now with fewer crossed fingers. Debian runs a provisioning layer with dnsmasq, nginx, PXE boot files, GRUB, and a Debian 13 arm64 preseed. OpenTofu talks to Pimox through qm, creates VM 9000 on local storage, boots it from the network, installs the OS, runs golden-node prep, disables swap, verifies cgroups, installs containerd and kubeadm tooling, then seals it as a template. Worker clones are idempotent by VMID when a stable non-local Pimox datastore is available.', 'blog_q9' => 'And OpenWrt is joining the story too?', - 'blog_a9' => 'OpenWrt remains an optional VM experiment in the kubeadm modes. Native K3s requires every Pimox VM stopped, so its pipeline skips OpenWrt startup. Pimox, its VM disks and vmbr0 remain in place. Switching back is a runtime transition, not permission to erase the hypervisor or run both modes together.', + 'blog_a9' => 'The earlier OpenWrt VM workflow has been retired. A separate isolated networking sandbox is planned; it is not part of the cluster deployment.', 'blog_q10' => 'What changed on the observability and scheduling side?', 'blog_a10' => 'The scheduler cares about reservations, placement and local volumes, not only current CPU consumption. Prometheus and Grafana once remained Pending because their retained storage pointed at a fully reserved one-core worker. The pipeline now estimates feasibility before applying, handles initial operator bootstrap separately, and still waits for actual readiness afterward. Old evicted pods are cleanup targets; a live Pending pod needs its scheduling cause fixed.', 'blog_stack_title' => 'Technologies and why they are here', @@ -170,7 +170,7 @@ return [ 'blog_stack_12' => 'The Pimox worker pipeline uses qm over SSH to create an OVMF/virtio-scsi Debian 13 arm64 VM, wait for qemu-guest-agent, seal it, and convert VM 9000 into a reusable template on local storage.', 'blog_stack_13' => 'The golden image bakes in Kubernetes prerequisites: swap disabled, cgroup boot options checked, kernel modules loaded, containerd configured for systemd cgroups, kubeadm/kubelet/kubectl installed, and qemu-guest-agent enabled.', 'blog_stack_14' => 'Worker clone automation is count-based and idempotent: LAB_PIMOX_WORKER_COUNT=1 means ensure VM 9010 exists, not create a fresh worker on every run. New workers are refused if the target storage is local.', - 'blog_stack_15' => 'OpenWrt is an opt-in firewall VM for VM mode. Native K3s skips it and refuses any running Pimox VM; the pipeline preserves the existing bridge and disks.', + 'blog_stack_15' => 'An isolated OpenWrt networking sandbox is planned separately from the cluster; its provisioning is not yet implemented.', 'blog_stack_16' => 'Prometheus Stack, Grafana, Loki, Promtail, node-exporter and kube-state-metrics make up the monitoring layer. Scheduling estimates include resource reservations and volume placement; live rollout checks determine whether the services actually started.', 'blog_stack_17' => 'The portfolio website keeps Apache at the core, runs PHP through PHP-FPM with OPcache, pre-renders read-heavy pages into static HTML during the image build, and leaves PHP for write and translation endpoints.', 'blog_stack_18' => 'The supply-chain path now uses BuildKit SBOM attestations, Cosign signatures, a cluster-published public key, and an audit-first Kyverno ImageValidatingPolicy that can be promoted to deny unsigned local-registry pods.', @@ -182,7 +182,7 @@ return [ 'blog_arch_title' => 'The homelab, end to end', 'blog_arch_intro_generated' => 'This diagram shows how source control, deployment, cluster profiles, and services fit together. It describes the intended architecture rather than live availability.', 'blog_arch_intro' => 'Git, builds, AI and recovery stay on Debian. Jeannie selects one of three Kubernetes layouts and checks identity, runtime exclusivity, scheduling and retained storage before changing it. The native Orange Pi K3s node has reported Ready; its platform and application rollout is tracked separately. The OCI edge still reaches services over Tailscale.', - 'blog_arch_caption' => 'The three profiles are alternatives, not simultaneous clusters. VM provisioning and OpenWrt belong to VM mode; native K3s uses the Orange Pi host directly. Retained disks and data survive mode changes, but storage moves require an explicit verified copy or restore.', + 'blog_arch_caption' => 'The three profiles are alternatives, not simultaneous clusters. Native K3s uses the Orange Pi host directly. Retained disks and data survive mode changes, but storage moves require an explicit verified copy or restore.', 'blog_arch_fun_link' => 'Open the Christmas-tree version', 'blog_activity_kicker' => 'Recent activity log', 'blog_activity_title' => 'What changed since the first build', @@ -198,7 +198,7 @@ return [ 'blog_activity_9' => 'Validated the full main-branch deployment path: fetch main, apply OpenTofu layers, build and push arm64 images, refresh Argo CD, and confirm the runner completes successfully.', 'blog_activity_10' => 'Built the Debian 13 arm64 Pimox template end to end with PXE, preseed, qemu-guest-agent discovery, cgroup validation, swap disabled, and a final seal step.', 'blog_activity_11' => 'Added Pimox worker clone automation so VM 9000 stays on local storage while worker nodes use a selected non-local datastore.', - 'blog_activity_12' => 'Added an opt-in OpenWrt VM path for a simple firewall between vmbr0 and vmbr1, with guardrails that avoid Orange Pi host networking changes.', + 'blog_activity_12' => 'Previously experimented with an OpenWrt VM workflow; that workflow has since been retired in preparation for an isolated sandbox.', 'blog_activity_13' => 'Installed the monitoring stack and moved platform add-ons such as Argo CD, Kyverno, and prometheus-stack work toward app-worker placement instead of treating the control plane as spare capacity.', 'blog_activity_14' => 'Reworked the website image to keep Apache as the web server while moving PHP execution to PHP-FPM, enabling OPcache, and validating the runtime through Gitea Actions instead of local image builds.', 'blog_activity_15' => 'Pre-rendered the read-heavy website pages into static HTML, moved visitor ideas behind a small JSON endpoint, added cache headers, enabled HTTP/2 and connection reuse at the OCI edge, and measured reused HTTP/2 asset loads around 60ms.', @@ -221,8 +221,8 @@ return [ 'blog_todo_10' => 'Tighten TLS, SSH, and token rotation around the OCI edge, Gitea, registry, and runner credentials.', 'blog_todo_11' => 'Restore any needed non-registry laptop PVC data explicitly, document its new host and path, and verify that switching profiles cannot bind the wrong local volume.', 'blog_todo_12' => 'Move sensitive app configuration into Sealed Secrets, External Secrets, or another explicit secret-management path.', - 'blog_todo_13' => 'Test the OpenWrt VM in a maintenance window before making it a gateway: confirm WAN, LAN, rollback access, DHCP settings, and that Pimox remains reachable.', - 'blog_todo_14' => 'Buy or configure a managed switch before VLAN work. Until then, keep OpenWrt as a simple two-interface firewall and avoid risky remote bridge rewrites.', + 'blog_todo_13' => 'Design an isolated OpenWrt sandbox with separate lifecycle controls and no cluster dependency.', + 'blog_todo_14' => 'Validate virtual VLAN isolation and sandbox firewall rules before connecting test clients.', 'blog_todo_15' => 'Turn the AI doctor path into a tighter loop: Holmes proposes the root cause, Jeannie records impact and confidence, and only allowlisted runbooks can become self-heal actions.', 'blog_ideas_kicker' => 'Visitor ideas', 'blog_ideas_title' => 'What would you improve next?', diff --git a/apps/website/lang/nah.php b/apps/website/lang/nah.php index 13cd36d..93c14a6 100644 --- a/apps/website/lang/nah.php +++ b/apps/website/lang/nah.php @@ -155,7 +155,6 @@ return [ 'blog_activity_9' => 'Validated full main-branch deployment path: fetch main, apply OpenTofu layers, build ihuan push arm64 images, refresh Argo CD, ihuan confirm runner completes successfully.', 'blog_activity_10' => 'Built Debian 13 arm64 Pimox template end to end ika PXE, preseed, qemu-guest-agent discovery, cgroup validation, swap disabled, ihuan final seal step.', 'blog_activity_11' => 'Added Pimox worker clone automation para VM 9000 ma mocahua ipan local storage mientras worker nodes use selected non-local datastore.', - 'blog_activity_12' => 'Added opt-in OpenWrt VM path para simple firewall between vmbr0 ihuan vmbr1, ika guardrails in avoid Orange Pi host networking changes.', 'blog_activity_13' => 'Installed monitoring stack ihuan moved platform add-ons such as Argo CD, Kyverno, ihuan prometheus-stack toward app-worker placement instead of treating control plane as spare capacity.', 'blog_activity_14' => 'Reworked website image para Apache ma mocahua web server while PHP runs through PHP-FPM, OPcache enabled, ihuan runtime validated through Gitea Actions instead of local image builds.', 'blog_activity_15' => 'Pre-rendered read-heavy website pages into static HTML, moved visitor ideas behind small JSON endpoint, added cache headers, enabled HTTP/2 ihuan connection reuse at OCI edge, ihuan measured reused HTTP/2 asset loads around 60ms.', @@ -174,8 +173,6 @@ return [ 'blog_todo_9' => 'Schedule backup restore drills para external Gitea ihuan OpenEBS volumes, then write exact restore runbook.', 'blog_todo_10' => 'Tighten TLS, SSH, ihuan token rotation around OCI edge, Gitea, registry, ihuan runner credentials.', 'blog_todo_12' => 'Move sensitive app configuration into Sealed Secrets, External Secrets, o occe explicit secret-management path.', - 'blog_todo_13' => 'Test the OpenWrt VM ipan maintenance window before making it a gateway: confirm WAN, LAN, rollback access, DHCP settings, ihuan Pimox remains reachable.', - 'blog_todo_14' => 'Buy o configure managed switch before VLAN work. Until then, keep OpenWrt quen simple two-interface firewall ihuan avoid risky remote bridge rewrites.', 'blog_todo_15' => 'Make AI doctor path tighter: Holmes proposes root cause, Jeannie records impact ihuan confidence, ihuan only allowlisted runbooks can become self-heal actions.', 'blog_ideas_kicker' => 'Visitor tlamachiliztli', 'blog_ideas_title' => 'Tlein tijpatlaz next?', diff --git a/bootstrap/provisioning/README.md b/bootstrap/provisioning/README.md index a3e9118..e586a0a 100644 --- a/bootstrap/provisioning/README.md +++ b/bootstrap/provisioning/README.md @@ -219,49 +219,3 @@ LAB_PIMOX_WORKER_REPLACE_EXISTING=true ./jeannie up LAB_PIMOX_HOST=192.168.100.80 LAB_PIMOX_BRIDGE=vmbr0 ./jeannie up ``` -## OpenWrt firewall VM - -OpenWrt is not built from the Debian golden-node template. The Kubernetes -template remains Debian-only; OpenWrt uses the upstream ARM SystemReady -`armsr/armv8` combined EFI image instead. - -The OpenWrt path is separate from the Kubernetes worker template. Run it only -after `vmbr1` exists on the Pimox host and the second NIC/LAN side is safe to -use: - -```bash -./jeannie openwrt -``` - -Defaults: - -- VMID `9100` -- VM name `openwrt-firewall` -- disk storage `opi5_ssd` when that Pimox storage is available -- WAN bridge `vmbr0` -- LAN bridge `vmbr1` -- LAN address `192.168.50.1/24` -- LAN DHCP disabled by default -- VM start disabled by default -- VM onboot disabled by default -- OpenWrt version `24.10.6` - -Useful overrides: - -```bash -LAB_OPENWRT_VMID=9100 -LAB_OPENWRT_STORAGE= -LAB_OPENWRT_WAN_BRIDGE=vmbr0 -LAB_OPENWRT_LAN_BRIDGE=vmbr1 -LAB_OPENWRT_LAN_IP=192.168.50.1 -LAB_OPENWRT_LAN_NETMASK=255.255.255.0 -LAB_OPENWRT_LAN_DHCP_ENABLED=false -LAB_OPENWRT_START=false -LAB_OPENWRT_ONBOOT=false -LAB_OPENWRT_VERSION=24.10.6 -LAB_OPENWRT_IMAGE_URL=https://downloads.openwrt.org/releases/24.10.6/targets/armsr/armv8/openwrt-24.10.6-armsr-armv8-generic-ext4-combined-efi.img.gz -``` - -The pipeline validates `vmbr0`, `vmbr1`, and the selected storage on the Pimox host. -It refuses `local` as OpenWrt storage and refuses to create or modify host -network bridges. diff --git a/cmd/jeannie-server/main.go b/cmd/jeannie-server/main.go index e63ed55..1072dd8 100644 --- a/cmd/jeannie-server/main.go +++ b/cmd/jeannie-server/main.go @@ -79,7 +79,7 @@ var allowedCommands = map[string]bool{ "security-secrets": true, "security-nuclei": true, "security-web": true, "security-logs": true, "security-runtime": true, "security-attack-path": true, "prompt-injection-lab": true, - "red-blue": true, "openwrt": true, "nuke": true, + "red-blue": true, "nuke": true, } type executeRequest struct { diff --git a/docs/architecture.md b/docs/architecture.md index c8b94dc..e7f0869 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -68,7 +68,7 @@ loader rather than maintaining a second copy of profile defaults. - creates a golden image install path with Kubernetes, containerd, qemu-guest-agent, cloud-init, and storage client packages ready - is used by the kubeadm VM profiles; native K3s skips worker provisioning - and OpenWrt VM startup, preserving Orange Pi host networking + and preserves Orange Pi host networking 2. `bootstrap/cluster` - installs the selected runtime: kubeadm on the laptop or Pimox CP VM, @@ -334,8 +334,7 @@ CIDR or upstream DNS servers change. ## MetalLB MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: +only after reserving a LAN IP range outside DHCP and other address pools: ```bash export TF_VAR_metallb='{ diff --git a/docs/deployment.md b/docs/deployment.md index 1ac278c..91f98f4 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -204,7 +204,7 @@ local registry, builds the website and demos images when their source changed, pushes them to the registry, recreates pods only after a new image is built, and applies the edge stack. -For native K3s, worker/template provisioning and OpenWrt VM startup are skipped. +For native K3s, worker/template provisioning is skipped. The selected native cluster is bootstrapped over SSH and uses the same platform and application layers with live single-node scheduling checks. Run `up` only after enrollment and after any existing transition has completed. @@ -263,15 +263,6 @@ worker tailnet egress against `${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and `${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - The website and demos images default to `linux/amd64,linux/arm64` because both deployments can schedule on either the Debian host or ARM workers. Override with `WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally @@ -649,7 +640,7 @@ the active step line refreshes with elapsed time and the latest log line. Set `JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or `JEANNIE_VERBOSE=true` to stream full command output. Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks +deploy/bootstrap, RPi services, Pimox workers, and OCI edge host checks can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential execution while troubleshooting, or raise it above the default `4` if the lab can absorb more concurrent work. diff --git a/docs/jeannie.1.md b/docs/jeannie.1.md index 53adfe7..1b0d7a5 100644 --- a/docs/jeannie.1.md +++ b/docs/jeannie.1.md @@ -37,7 +37,7 @@ AI, and destructive commands. `up` : Deploy the full homelab pipeline. Runs early preflight, deploys Gitea and RPi services, runs full preflight and pre-apply doctor checks, then applies Pimox, -OpenWrt, cluster, platform, apps, and edge stacks. +cluster, platform, apps, and edge stacks. `plan [all|provisioning|cluster|platform|apps|edge]` : Run OpenTofu plans without applying changes. The default target is `all`. @@ -274,9 +274,6 @@ needed. : Ensure the configured Gitea repository, branch, remotes, and host SSH key are ready. -`openwrt` -: Apply the OpenWrt VM stack. - ### Gitea Operations `backup-gitea` diff --git a/docs/templates/architecture.md.tmpl b/docs/templates/architecture.md.tmpl index ad604d5..01405ea 100644 --- a/docs/templates/architecture.md.tmpl +++ b/docs/templates/architecture.md.tmpl @@ -68,7 +68,7 @@ loader rather than maintaining a second copy of profile defaults. - creates a golden image install path with Kubernetes, containerd, qemu-guest-agent, cloud-init, and storage client packages ready - is used by the kubeadm VM profiles; native K3s skips worker provisioning - and OpenWrt VM startup, preserving Orange Pi host networking + and preserves Orange Pi host networking 2. `bootstrap/cluster` - installs the selected runtime: kubeadm on the laptop or Pimox CP VM, @@ -334,8 +334,7 @@ CIDR or upstream DNS servers change. ## MetalLB MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: +only after reserving a LAN IP range outside DHCP and other address pools: ```bash export TF_VAR_metallb='{ diff --git a/docs/templates/deployment.md.tmpl b/docs/templates/deployment.md.tmpl index 8ed653d..44bf434 100644 --- a/docs/templates/deployment.md.tmpl +++ b/docs/templates/deployment.md.tmpl @@ -204,7 +204,7 @@ local registry, builds the website and demos images when their source changed, pushes them to the registry, recreates pods only after a new image is built, and applies the edge stack. -For native K3s, worker/template provisioning and OpenWrt VM startup are skipped. +For native K3s, worker/template provisioning is skipped. The selected native cluster is bootstrapped over SSH and uses the same platform and application layers with live single-node scheduling checks. Run `up` only after enrollment and after any existing transition has completed. @@ -263,15 +263,6 @@ worker tailnet egress against `${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and `${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - The website and demos images default to `linux/amd64,linux/arm64` because both deployments can schedule on either the Debian host or ARM workers. Override with `WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally @@ -649,7 +640,7 @@ the active step line refreshes with elapsed time and the latest log line. Set `JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or `JEANNIE_VERBOSE=true` to stream full command output. Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks +deploy/bootstrap, RPi services, Pimox workers, and OCI edge host checks can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential execution while troubleshooting, or raise it above the default `4` if the lab can absorb more concurrent work. diff --git a/jeannie b/jeannie index 8ea4db5..c4b68b0 100755 --- a/jeannie +++ b/jeannie @@ -208,7 +208,7 @@ Apps And Services website-translation-model Prepare website translation model support. website-ollama-listen Configure website Ollama access. install-gitea-runner [TOKEN] Install the Gitea Actions runner. - openwrt Deploy/check OpenWrt lab config. + network-sandbox plan Inspect proposed isolated network lab. Security Learning security-scan Run the security scan bundle. @@ -788,8 +788,13 @@ case "${1:-}" in red-blue) red_blue_loop "$@" ;; - openwrt) - openwrt + network-sandbox) + require_debian_server "network-sandbox" + if [[ "${2:-plan}" != "plan" || $# -gt 2 ]]; then + echo "Usage: ./jeannie network-sandbox plan" >&2 + exit 2 + fi + python3 "${REPO_ROOT}/scripts/network-sandbox-plan.py" ;; nuke) record_change_journal "nuke" "$@" diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index bfb62d4..b80af90 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -177,12 +177,11 @@ rebuild_cluster() { echo "Rebuilding the Kubernetes cluster without touching external Gitea..." jeannie_log_start "rebuild-cluster" - jeannie_step_plan 10 + jeannie_step_plan 9 run_step "Preflight" homelab_preflight run_step "Nuke existing cluster state" nuke_for_rebuild run_step "Pimox provisioning and workers" run_pimox_pipeline - run_step "OpenWrt VM" run_openwrt_pipeline run_step "Worker var file" ensure_cluster_worker_var_file run_step "Cluster OpenTofu apply" run_tofu_stack "bootstrap/cluster" run_step "Version report" doctor_versions_report diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index a83efd3..9c164c4 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -4218,349 +4218,6 @@ fi" 2>&1)" export LAB_CLUSTER_VAR_FILE="${var_file}" } -run_openwrt_pipeline() { - local mode="${LAB_OPENWRT_VM:-${LAB_OPENWRT_PIPELINE:-false}}" - local pimox_host="${LAB_PIMOX_HOST:-${TF_VAR_pimox_host:-192.168.100.80}}" - local pimox_user="${LAB_PIMOX_USER:-${TF_VAR_pimox_user:-jv}}" - local pimox_key="${LAB_PIMOX_SSH_KEY_PATH:-${TF_VAR_pimox_ssh_key_path:-/home/jv/.ssh/id_ed25519}}" - local qm_bin="${LAB_PIMOX_QM_BIN:-${TF_VAR_pimox_qm_bin:-/usr/sbin/qm}}" - local vmid="${LAB_OPENWRT_VMID:-9100}" - local vm_name="${LAB_OPENWRT_NAME:-openwrt-firewall}" - local storage="${LAB_OPENWRT_STORAGE:-opi5_ssd}" - local wan_bridge="${LAB_OPENWRT_WAN_BRIDGE:-vmbr0}" - local lan_bridge="${LAB_OPENWRT_LAN_BRIDGE:-vmbr1}" - local cores="${LAB_OPENWRT_CORES:-2}" - local memory="${LAB_OPENWRT_MEMORY:-512}" - local version="${LAB_OPENWRT_VERSION:-24.10.6}" - local image_url="${LAB_OPENWRT_IMAGE_URL:-}" - local lan_ip="${LAB_OPENWRT_LAN_IP:-192.168.50.1}" - local lan_netmask="${LAB_OPENWRT_LAN_NETMASK:-255.255.255.0}" - local lan_dhcp_enabled="${LAB_OPENWRT_LAN_DHCP_ENABLED:-false}" - local start_vm="${LAB_OPENWRT_START:-false}" - local onboot="${LAB_OPENWRT_ONBOOT:-false}" - local root_key_path="${LAB_OPENWRT_ROOT_SSH_PUBLIC_KEY_PATH:-${pimox_key}.pub}" - local root_key_b64="" - local lan_dhcp_ignore="1" - local start_vm_flag="false" - local onboot_flag="0" - - if disabled_value "${mode}"; then - return 0 - fi - if ! truthy "${mode}"; then - echo "LAB_OPENWRT_VM must be true or false." >&2 - exit 1 - fi - cluster_runtime_require --vm-start || return 1 - - if [[ -z "${image_url}" ]]; then - image_url="https://downloads.openwrt.org/releases/${version}/targets/armsr/armv8/openwrt-${version}-armsr-armv8-generic-ext4-combined-efi.img.gz" - fi - - if ! [[ "${vmid}" =~ ^[0-9]+$ ]]; then - echo "LAB_OPENWRT_VMID must be a numeric Pimox VMID." >&2 - exit 1 - fi - for value_name in storage wan_bridge lan_bridge vm_name; do - local value="${!value_name}" - if ! [[ "${value}" =~ ^[A-Za-z0-9_.:-]+$ ]]; then - echo "LAB_OPENWRT_${value_name^^} contains unsupported characters." >&2 - exit 1 - fi - done - if [[ "${storage}" == "local" ]]; then - echo "LAB_OPENWRT_STORAGE cannot be local; reserve local storage for the Pimox Debian template." >&2 - exit 1 - fi - if ! [[ "${lan_ip}" =~ ^[0-9.]+$ && "${lan_netmask}" =~ ^[0-9.]+$ ]]; then - echo "LAB_OPENWRT_LAN_IP and LAB_OPENWRT_LAN_NETMASK must be IPv4-style values." >&2 - exit 1 - fi - if truthy "${lan_dhcp_enabled}"; then - lan_dhcp_ignore="0" - fi - if ! truthy "${start_vm}" && ! disabled_value "${start_vm}"; then - echo "LAB_OPENWRT_START must be true or false." >&2 - exit 1 - fi - if truthy "${start_vm}"; then - start_vm_flag="true" - fi - if ! truthy "${onboot}" && ! disabled_value "${onboot}"; then - echo "LAB_OPENWRT_ONBOOT must be true or false." >&2 - exit 1 - fi - if truthy "${onboot}"; then - onboot_flag="1" - fi - if [[ -r "${root_key_path}" ]]; then - root_key_b64="$(base64 <"${root_key_path}" | tr -d '\n')" - fi - - echo "Preparing OpenWrt firewall VM ${vmid} on ${pimox_host}; validating ${wan_bridge}, ${lan_bridge}, and ${storage} without changing Orange Pi networking..." - pimox_ssh "${pimox_host}" "${pimox_user}" "${pimox_key}" "bash -s" <&2 - exit 1 -fi - -pvesm_cmd="\$(command -v pvesm 2>/dev/null || true)" -if [ -z "\$pvesm_cmd" ] && [ -x /usr/sbin/pvesm ]; then - pvesm_cmd=/usr/sbin/pvesm -fi -if [ -z "\$pvesm_cmd" ]; then - echo "pvesm was not found; cannot validate Pimox storage \$storage" >&2 - exit 1 -fi - -if ! sudo -n true >/dev/null 2>&1; then - echo "passwordless sudo is required for OpenWrt VM automation" >&2 - exit 1 -fi -if ! ip link show "\$wan_bridge" >/dev/null 2>&1; then - echo "WAN bridge \$wan_bridge does not exist. Refusing to change Orange Pi networking." >&2 - exit 1 -fi -if ! ip link show "\$lan_bridge" >/dev/null 2>&1; then - echo "LAN bridge \$lan_bridge does not exist. Create it manually before enabling OpenWrt automation." >&2 - exit 1 -fi -if ! sudo "\$pvesm_cmd" status | awk -v storage="\$storage" 'NR > 1 && \$1 == storage { found = 1 } END { exit found ? 0 : 1 }'; then - echo "Pimox storage \$storage was not found." >&2 - exit 1 -fi - -if sudo "\$qm_cmd" status "\$vmid" >/dev/null 2>&1; then - if sudo "\$qm_cmd" config "\$vmid" | grep -q '^template: 1$'; then - echo "VM \$vmid exists as a template; refusing to reuse it for OpenWrt." >&2 - exit 1 - fi - sudo "\$qm_cmd" set "\$vmid" \\ - --net0 "virtio,bridge=\$wan_bridge" \\ - --net1 "virtio,bridge=\$lan_bridge" \\ - --cores "\$cores" \\ - --memory "\$memory" \\ - --onboot "\$onboot" - if [ "\$start_vm" = "true" ] && sudo "\$qm_cmd" status "\$vmid" | grep -q 'status: stopped'; then - sudo "\$qm_cmd" start "\$vmid" - fi - exit 0 -fi - -for required_cmd in curl gzip losetup mount umount awk sed; do - if ! command -v "\$required_cmd" >/dev/null 2>&1; then - echo "\$required_cmd is required on the Pimox host for OpenWrt image preparation" >&2 - exit 1 - fi -done - -tmp_dir="\$(mktemp -d /tmp/homelab-openwrt.XXXXXX)" -mnt_dir="\$tmp_dir/root" -loopdev="" -cleanup() { - if mountpoint -q "\$mnt_dir" 2>/dev/null; then - sudo umount "\$mnt_dir" || sudo umount -l "\$mnt_dir" || true - fi - if [ -n "\$loopdev" ]; then - sudo losetup -d "\$loopdev" >/dev/null 2>&1 || true - fi - rm -rf "\$tmp_dir" -} -trap cleanup EXIT - -mkdir -p "\$mnt_dir" -curl -fsSL "\$image_url" -o "\$tmp_dir/openwrt.img.gz" -gzip -dc "\$tmp_dir/openwrt.img.gz" >"\$tmp_dir/openwrt.img" - -loopdev="\$(sudo losetup --find --partscan --show "\$tmp_dir/openwrt.img")" -root_part="\${loopdev}p2" -if [ ! -b "\$root_part" ] && echo "\$loopdev" | grep -q 'loop[0-9]\$'; then - root_part="\${loopdev}p2" -fi -if [ ! -b "\$root_part" ]; then - echo "Could not find OpenWrt root partition \$root_part after attaching image." >&2 - exit 1 -fi - -sudo mount "\$root_part" "\$mnt_dir" -sudo mkdir -p "\$mnt_dir/etc/config" "\$mnt_dir/etc/dropbear" "\$mnt_dir/root/.ssh" - -cat >"\$tmp_dir/network" <"\$tmp_dir/dhcp" <"\$tmp_dir/firewall" <<'FIREWALL' -config defaults - option input 'REJECT' - option output 'ACCEPT' - option forward 'REJECT' - option synflood_protect '1' - -config zone - option name 'lan' - list network 'lan' - option input 'ACCEPT' - option output 'ACCEPT' - option forward 'ACCEPT' - -config zone - option name 'wan' - list network 'wan' - option input 'REJECT' - option output 'ACCEPT' - option forward 'REJECT' - option masq '1' - option mtu_fix '1' - -config forwarding - option src 'lan' - option dest 'wan' - -config rule - option name 'Allow-DHCP-Renew' - option src 'wan' - option proto 'udp' - option dest_port '68' - option target 'ACCEPT' - option family 'ipv4' - -config rule - option name 'Allow-Ping' - option src 'wan' - option proto 'icmp' - option icmp_type 'echo-request' - option family 'ipv4' - option target 'ACCEPT' -FIREWALL - -cat >"\$tmp_dir/system" <"\$tmp_dir/authorized_keys" - sudo cp "\$tmp_dir/authorized_keys" "\$mnt_dir/etc/dropbear/authorized_keys" - sudo cp "\$tmp_dir/authorized_keys" "\$mnt_dir/root/.ssh/authorized_keys" - sudo chmod 0600 "\$mnt_dir/etc/dropbear/authorized_keys" "\$mnt_dir/root/.ssh/authorized_keys" -fi -sync -sudo umount "\$mnt_dir" -sudo losetup -d "\$loopdev" -loopdev="" - -sudo "\$qm_cmd" create "\$vmid" \\ - --name "\$vm_name" \\ - --bios ovmf \\ - --cores "\$cores" \\ - --memory "\$memory" \\ - --net0 "virtio,bridge=\$wan_bridge" \\ - --net1 "virtio,bridge=\$lan_bridge" \\ - --numa 0 \\ - --ostype l26 \\ - --scsihw virtio-scsi-pci \\ - --sockets 1 \\ - --vga virtio \\ - --onboot "\$onboot" - -sudo "\$qm_cmd" set "\$vmid" --efidisk0 "\$storage:1,efitype=4m,pre-enrolled-keys=0" -sudo "\$qm_cmd" importdisk "\$vmid" "\$tmp_dir/openwrt.img" "\$storage" --format raw >/dev/null -disk_volume="\$(sudo "\$qm_cmd" config "\$vmid" | awk -F': ' '/^unused[0-9]+:/ { print \$2; exit }')" -if [ -z "\$disk_volume" ]; then - echo "Could not find imported OpenWrt disk volume for VM \$vmid" >&2 - exit 1 -fi -sudo "\$qm_cmd" set "\$vmid" --scsi0 "\$disk_volume" -sudo "\$qm_cmd" set "\$vmid" --boot "order=scsi0" - -if [ "\$start_vm" = "true" ]; then - sudo "\$qm_cmd" start "\$vmid" -fi -EOF -} - -openwrt() { - require_debian_server "openwrt" - - LAB_OPENWRT_VM=true run_openwrt_pipeline -} - cleanup_calico_links() { ip link show | awk -F: '/^[0-9]+: cali/ {print $2}' | cut -d@ -f1 | xargs -r -n1 sudo ip link delete 2>/dev/null || true sudo ip link delete vxlan.calico 2>/dev/null || true @@ -9153,11 +8810,6 @@ spec = { "title": "Pimox provisioning and workers", "command": [jeannie, "__up-task", "pimox-workers"], }, - { - "id": "openwrt", - "title": "OpenWrt VM", - "command": [jeannie, "__up-task", "openwrt"], - }, { "id": "edge-host", "title": "OCI edge host check", @@ -9230,13 +8882,6 @@ up_task() { fi run_pimox_pipeline ;; - openwrt) - if [[ "${LAB_CLUSTER_RUNTIME:-kubeadm}" == k3s ]]; then - echo "Skipping OpenWrt VM startup while direct-host K3s is selected." - return 0 - fi - run_openwrt_pipeline - ;; edge-host) check_edge_ssh ;; diff --git a/scripts/network-sandbox-plan.py b/scripts/network-sandbox-plan.py new file mode 100644 index 0000000..ffb2119 --- /dev/null +++ b/scripts/network-sandbox-plan.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +"""Read-only feasibility report for the proposed isolated OpenWrt lab.""" +import json +import os +import subprocess +import sys + + +def main(): + host = os.environ.get('LAB_PIMOX_HOST', '192.168.100.80') + user = os.environ.get('LAB_PIMOX_USER', 'jv') + key = os.environ.get('LAB_PIMOX_SSH_KEY_PATH', '/home/jv/.ssh/id_ed25519') + remote = '''set -eu +printf '%s\\n' '---vms---' +sudo -n qm list +printf '%s\\n' '---containers---' +sudo -n pct list +printf '%s\\n' '---bridges---' +ip -brief link show type bridge +printf '%s\\n' '---storage---' +sudo -n pvesm status --content rootdir +printf '%s\\n' '---data---' +findmnt -rn -M /data -o SOURCE,FSTYPE,OPTIONS +printf '%s\\n' '---architecture---' +uname -m +''' + try: + result = subprocess.run(['ssh', '-T', '-i', key, '-o', 'BatchMode=yes', + '-o', 'IdentitiesOnly=yes', '-o', 'ConnectTimeout=10', + '-o', 'StrictHostKeyChecking=accept-new', + f'{user}@{host}', remote], + capture_output=True, text=True, timeout=45, check=True) + sections = {} + section = None + for line in result.stdout.splitlines(): + if line.startswith('---') and line.endswith('---'): + section = line.strip('-') + sections[section] = [] + elif section: + sections[section].append(line) + if set(sections) != {'vms', 'containers', 'bridges', 'storage', 'data', 'architecture'}: + raise ValueError('Incomplete host report') + guests = {} + for kind in ('vms', 'containers'): + guests[kind] = [line.split()[:3] for line in sections[kind] + if line.split() and line.split()[0].isdigit()] + report = { + 'mode': 'read-only planning; sandbox creation is not implemented', + 'host_architecture': ' '.join(sections['architecture']), + 'proposed_vm': {'id': 9100, 'role': 'OpenWrt router'}, + 'proposed_containers': [{'id': 9110, 'vlan': 10}, {'id': 9111, 'vlan': 20}], + 'guest_ids_in_use': [entry for values in guests.values() for entry in values + if entry[0] in {'9100', '9110', '9111'}], + 'bridge_inventory': sections['bridges'], + 'container_storage': sections['storage'], + 'data_mount': sections['data'], + 'requirements': [ + 'Dedicated bridge without physical ports; preserve vmbr0 and vmbr1', + 'Explicit sandbox guest identity and cluster-runtime guard changes', + 'ARM64 Alpine template compatibility on this Pimox/LXC version', + 'Dedicated SSD storage supporting container root filesystems', + 'OpenWrt firewall blocking home, cluster, and tailnet networks', + 'Guest provisioning, lifecycle, isolation and recovery validation', + ], + } + print(json.dumps(report, indent=2)) + except (OSError, ValueError, subprocess.SubprocessError) as exc: + print(f'Network sandbox plan failed: {exc}', file=sys.stderr) + return 1 + return 0 + + +if __name__ == '__main__': + sys.exit(main())