Skip to content

playbook: §12b m2o desktop provisioning (RDP + console-auth + m2gw) - #5

Closed
mariuszkreft wants to merge 4 commits into
mainfrom
playbook/m2o-provision-notes
Closed

playbook: §12b m2o desktop provisioning (RDP + console-auth + m2gw)#5
mariuszkreft wants to merge 4 commits into
mainfrom
playbook/m2o-provision-notes

Conversation

@mariuszkreft

Copy link
Copy Markdown
Contributor

Reopens after PR #4 was closed with the branch deleted. Same content plus the m2-gpt provisioning slice at the end.

What this adds

§12b — m2o Desktop Provisioning (RDP + cross-host Guacamole + console/ttyd + m2gw) in PLAYBOOK.md.

One-command wrapper: scripts/launch-m2o-desktop.sh

Idempotent end-to-end desktop bring-up. Runs provision.sh, waits for healthy (tolerating the ~2 min first-boot rm -rf /home), creates the guacd socat relay on m2.2, upserts the Guacamole RDP row on m2, grants perms — and with --provision-m2gw also does the m2-gpt work below. Installed on both hosts as launch-desktop.sh.

Companion: scripts/m2gw-provision-agent.sh

Creates the tenant + agent (configurable route chain), mints a per-agent bearer, patches the target desktop's Hermes config.yaml (model.default + model.api_key), restarts hermes-gateway. Runs on m2 or SSHes there from m2.2. Defaults: spark-glm (glm-5.3-flash, vision) → deepseek-spark (deepseek-v4-flash-0731) fallback.

Fixes

  • desktop/provision.sh (both hosts) — Traefik Host() was hardcoded to m2o.machinemachine.ai, silently breaking /console/<name> for every m2.2 desktop. Now reads CONSOLE_PUBLIC_HOST from console-auth/secrets.env (m2.2 sets it to console.m-2.cc).
  • scripts/launch-m2o-desktop.sh — removed the docker restart guacamole-full step (invalidated every active user's session cookie; Guacamole picks up DB changes on next session anyway).

Deployed as side-effects (not just documented)

  • Built + deployed the pre-existing m2o-console-link Guacamole extension — adds a Console ↗ button to each connection tile on the home page.
  • Added CONSOLE_HOST_OVERRIDES env support to console-auth/app.py so m2.2 desktops get console.m-2.cc URLs from /issue and /issue-web. launch-desktop.sh auto-maintains the map on new m2.2 desktops.
  • Brought up euroclean-m2o end-to-end: container (m2.2) → Guacamole (m2) via socat relay → console-auth magic-link flow → m2-gpt tenant/agent/bearer + Hermes wired to spark-glm → deepseek-spark.

Test plan

  • launch-desktop.sh euroclean on m2.2 — idempotent re-run reuses container, relay, connection.
  • Guacamole Euroclean Desktop visible to guacadmin + m2.
  • /console/euroclean/ end-to-end: token accepted → 302 → session cookie → 200.
  • Console ↗ button appears on the Guacamole home page and mints per-desktop URLs on the right host.
  • m2gw-provision-agent.sh euroclean-m2o --skip-hermes — tenant reused, agent chain updated, fresh bearer minted.
  • Gateway → chain → LLM smoke: curl gpt.machinemachine.ai/v1/chat/completions with the new bearer returns 200 and the requested content.
  • bash -n on all shell scripts.

🤖 Generated with Claude Code

mariuszkreft and others added 4 commits August 24, 2026 11:25
Captures the m2 / m2.2 host topology, path & DNS gotchas, first-boot
`unhealthy` window, expected WARNs on m2.2, and the socat-relay pattern
for wiring m2.2-hosted desktops into m2's Guacamole (guacamole-full).

Adds `scripts/launch-m2o-desktop.sh`, an idempotent wrapper that runs
provision.sh, waits for healthy, creates the guacd relay (m2.2 only),
upserts the Guacamole RDP row on m2, and grants perms — one command
end-to-end. Installed on both hosts as `launch-desktop.sh`.

Amendment trigger: pattern that had to be reconstructed from scratch
during euroclean-m2o provisioning (2026-08-24) — belongs in the playbook.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the Console (ttyd, magic-link flow) subsection to §12b: there is
only ONE real console-auth in the fleet (on m2). m2.2 desktops route
via m2.2 Traefik → local console-auth socat → m2's console-auth-lan-relay
→ real console-auth. Documents the two per-desktop sync requirements
(Traefik Host + m2's CONSOLE_BASIC_CREDS) and the admin curl to mint
magic links.

Notes the provision.sh bug (fixed 2026-08-24 on both hosts): the
Traefik router Host() was hardcoded to m2o.machinemachine.ai, so
/console/<name> silently 404'd for every m2.2-hosted desktop.
provision.sh now reads CONSOLE_PUBLIC_HOST from console-auth/secrets.env.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… fix session-wipe

Docs the m2o-console-link Guacamole extension (built + deployed this
session): tiny JS/CSS extension that adds a Console ↗ button to each
row on the Guacamole home page. Click → POST /console-mint/issue-web
with the current session token → console-auth validates against the
Guacamole REST API and mints a magic link for that desktop. Traefik
route /console-mint/* → console-auth was already in place.

For the m2.2 desktops the URL must be console.m-2.cc, not the default
m2o.machinemachine.ai. Adds CONSOLE_HOST_OVERRIDES env to console-auth
(JSON slug → host map) and threads it through _host_for(desktop).
launch-desktop.sh now auto-adds the new desktop to this map and
redeploys console-auth on m2 when provisioning on m2.2.

Also removes the accidental `docker restart guacamole-full` from
launch-desktop.sh — Guacamole picks up DB changes on next session, so
the restart was gratuitous AND invalidated every active user's cookie
(operator saw the connection list briefly "disappear" until re-login).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds `scripts/m2gw-provision-agent.sh` — one idempotent command that
creates a tenant, upserts the agent with a configurable route chain,
mints a bearer, and (optionally) patches a target desktop's Hermes
config.yaml. Runs on m2 or SSH-in from m2.2. Installed on both hosts
alongside launch-desktop.sh and in ~/m2-gpt/m2-gpt/scripts/ on m2.

Threads a new `--provision-m2gw` flag through launch-desktop.sh so
desktop spawn + gateway wire is a single command. New flags
--m2gw-primary/--m2gw-fallback/--m2gw-model/--m2gw-principal let the
caller pick a different route chain than the default (spark-glm ->
deepseek-spark, model=m2gw-spark-glm/glm-5.3-flash).

§12b in the playbook gets a "Provisioning the m2-gpt tenant / agent /
bearer" subsection with the rationale (per-desktop bearer vs the
fleet-wide placeholder baked in by provision.sh), the introspection
one-liner for the routes table, and a note that deepseek-v4-3107 isn't
deployed today — the fleet standard text route is
deepseek-v4-flash-0731.

euroclean-m2o brought up end-to-end this session: tenant + agent
(chain: spark-glm -> deepseek-spark), per-agent bearer minted, Hermes
config on euroclean-m2o updated to use it with
model.default=m2gw-spark-glm/glm-5.3-flash. Gateway -> chain -> LLM
smoke passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mariuszkreft
mariuszkreft deleted the playbook/m2o-provision-notes branch August 28, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant