feat: monky-deployd v0.1.0 — pull agent over the mesh (ADR-0028)

Stdlib-only Python 3.12 agent for docker VMs and laptops: flock → checkin
(bearer = the agent's OpenBao token, bootstrapped from the install kit's
jwt-tenancy deploy grant) → action apply|none|down → bundle (sha256
verified) → refusal checks (unresolved ${VAR} names only, manifest paths
pinned to monky/data/<env>/see/, privileged/host-network, rollback, disk
need×1.5+headroom) → lease → POST /v1/auth/jwt-tenancy/login → KV reads →
.env 0600 → promote → compose pull/up → wait healthy → report; finally
renew-self / re-lease before max TTL, scrub. Exit 0/75/78/1. Redactor log
filter. Transports sdk (openziti) / proxy (ziti tunnel proxy 18443/18200) /
system. Laptop mode.

Packaging: hardened oneshot + 60 s timer + proxy unit, nfpm .deb with
/opt/monky-deployd/venv, install.sh for Ubuntu 26.04 (Gitea release
download, enrol, ACLs, bootstrap from stdin), ansible role skeleton for
osg1-07. CI: lint/test on every change; wheel (openziti on ubuntu:26.04) and
package (nfpm) allow_failure until runner egress is proven; GitLab release +
release:gitea on v* tags. Docs: README, PROTOCOL, OPERATIONS, CHANGELOG,
CLAUDE/AGENTS.

Divergence noted: monky-tenancy main (MR !15) still ships the AppRole lease
and kit; this agent implements the plan's Gate 1 RESULT (login_jwt, no
unwrap) and refuses an AppRole lease loudly (LEASE_SHAPE).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLB7jieMNRkTsJ2epr4Ds1
This commit is contained in:
2026-09-05 08:01:36 +00:00
parent c72d6c0227
commit 1c42e913a8
48 changed files with 4932 additions and 64 deletions
@@ -0,0 +1,42 @@
# Fallback transport (b): `ziti tunnel proxy` publishes the two mesh services on loopback so the
# agent (transport: proxy) can reach them without the Python SDK. Runs as user ziti with the
# SAME host identity ziti-edge-tunnel run-host uses. Enable only with `transport: proxy`.
# monky.tenancy.deploy -> 127.0.0.1:18443 (plain HTTP inside the mesh)
# openbao -> 127.0.0.1:18200 (TLS end-to-end; SNI bao.cbs.tikali.net)
# NOTE: `ziti tunnel proxy` listens on IPv4 0.0.0.0 only (see project_openbao_consumer_gateway);
# the agent dials 127.0.0.1, so that is fine here.
[Unit]
Description=ziti tunnel proxy for monky-deployd (transport: proxy)
Documentation=https://scm.tikali.ai/tikali/applications/monky/monky-deployd
After=network-online.target
Wants=network-online.target
ConditionPathExists=/etc/monky-deployd/proxy.env
[Service]
Type=simple
User=ziti
Group=ziti
# proxy.env sets ZITI_IDENTITY=/opt/openziti/etc/identities/monky-host.<env>.json
EnvironmentFile=/etc/monky-deployd/proxy.env
ExecStart=/usr/bin/ziti tunnel proxy -i ${ZITI_IDENTITY} monky.tenancy.deploy:18443 openbao:18200
Restart=always
RestartSec=5s
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictSUIDSGID=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
CapabilityBoundingSet=
ReadOnlyPaths=-/opt/openziti/etc/identities
IPAddressDeny=any
IPAddressAllow=localhost
# the mesh edge routers are dialled by the ziti library itself: allow egress everywhere but
# only accept on loopback (the listeners bind 0.0.0.0 — IPAddressAllow above limits who connects)
IPAddressAllow=0.0.0.0/0 ::/0
[Install]
WantedBy=multi-user.target
+55
View File
@@ -0,0 +1,55 @@
# monky-deployd — one reconcile tick (MONKY-ADR-0028 §D). Fired by monky-deployd.timer.
[Unit]
Description=Monky backend pull agent (one tick: checkin -> bundle -> lease -> OpenBao -> compose -> report)
Documentation=https://scm.tikali.ai/tikali/applications/monky/monky-deployd
After=network-online.target docker.service ziti-edge-tunnel.service
Wants=network-online.target
# The proxy transport needs the local ziti proxy; harmless when the unit is disabled.
After=monky-deployd-proxy.service
ConditionPathExists=/etc/monky-deployd/config.yaml
[Service]
Type=oneshot
User=monky-deployd
Group=monky-deployd
SupplementaryGroups=docker
ExecStart=/usr/bin/monky-deployd run --once
# 75 = temporary network failure (next tick retries), 78 = AGENT_ENV_MISMATCH (operator action)
SuccessExitStatus=75
TimeoutStartSec=20min
Nice=5
Environment=PYTHONUNBUFFERED=1
Environment=MONKY_DEPLOYD_CONFIG=/etc/monky-deployd/config.yaml
UMask=0077
# hardening
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictSUIDSGID=yes
RestrictRealtime=yes
LockPersonality=yes
# (no MemoryDenyWriteExecute: the openziti SDK's ctypes callbacks need libffi trampolines)
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
CapabilityBoundingSet=
AmbientCapabilities=
StateDirectory=monky-deployd
StateDirectoryMode=0700
ReadWritePaths=/var/lib/monky-deployd
# the bootstrap grant is deleted after the first login (the only write under /etc)
ReadWritePaths=/etc/monky-deployd
ReadOnlyPaths=-/opt/openziti/etc/identities
# docker socket + compose need the socket path writable
ReadWritePaths=-/var/run/docker.sock -/run/docker.sock
[Install]
WantedBy=multi-user.target
+14
View File
@@ -0,0 +1,14 @@
# Every 60 s after the previous tick finished (+ up to 10 s jitter); flock in the agent prevents overlap.
[Unit]
Description=Monky backend pull agent tick timer
Documentation=https://scm.tikali.ai/tikali/applications/monky/monky-deployd
[Timer]
OnBootSec=90s
OnUnitActiveSec=60s
RandomizedDelaySec=10s
AccuracySec=1s
Unit=monky-deployd.service
[Install]
WantedBy=timers.target