mirror of
https://scm.tikali.ai/tikali/applications/monky/monky-deployd.git
synced 2026-09-18 04:36:15 +00:00
fix: accept sites fmt|cbs|pdx|roam (tenancy 0.7.x) and keep the identity read grant alive across tunneller rewrites — 0.1.10
deployd#3 (DD-0620): every kit for a backend registered since 2026-09-08 died at `--site`. env-dev-08 (2026-09-11..13): two days of "identity is not readable" ticks — ziti-edge-tunnel re-creates the file with mode 0600, the ACL mask goes to ---, group membership stops helping. identity-acl.sh + monky-deployd-identity-acl.path re-apply the grant on every directory change. Doc-Drift: DD-0620 fixed Closes #3 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ASnneBmT7rfaJLE8NGNw7S
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# monky-deployd: (re)grant the agent read access to the host's ziti identity file(s).
|
||||
# Idempotent; safe to run at any time. Invoked by install.sh, the package postinstall and the
|
||||
# monky-deployd-identity-acl.path unit (whenever the identity directory changes).
|
||||
#
|
||||
# Why a re-runnable script and not a one-time ACL: ziti-edge-tunnel re-creates the identity on
|
||||
# every controller config update with mode 0600. On a file with an ACL that sets the mask to ---,
|
||||
# so the named-user entry AND the ziti-group read both become ineffective. Only re-applying the
|
||||
# entries after each rewrite keeps the agent alive.
|
||||
set -eu
|
||||
DIR="${1:-/opt/openziti/etc/identities}"
|
||||
[ -d "$DIR" ] || exit 0
|
||||
command -v setfacl >/dev/null 2>&1 || exit 0
|
||||
setfacl -m u:monky-deployd:rx,m::rx "$DIR" 2>/dev/null || true
|
||||
setfacl -d -m u:monky-deployd:r,m::r "$DIR" 2>/dev/null || true
|
||||
for f in "$DIR"/*.json; do
|
||||
[ -f "$f" ] || continue
|
||||
setfacl -m u:monky-deployd:r,m::r "$f" 2>/dev/null || true
|
||||
done
|
||||
exit 0
|
||||
@@ -4,7 +4,7 @@
|
||||
# T=<read-only GitLab deploy token, scope read_package_registry> # from the install kit / OpenBao
|
||||
# curl -sSf -H "DEPLOY-TOKEN: $T" \
|
||||
# https://scm.tikali.ai/api/v4/projects/69/packages/generic/monky-deployd/0.1.6/install.sh \
|
||||
# | sudo bash -s -- --env env-qa-02 --site cbs --token "$T" --bootstrap-file bootstrap.jwt \
|
||||
# | sudo bash -s -- --env env-qa-02 --site fmt --token "$T" --bootstrap-file bootstrap.jwt \
|
||||
# [--transport sdk|proxy|system] [--version 0.1.6] [--enrol-jwt /path/monky-host.env-qa-02.jwt] \
|
||||
# [--laptop] [--source gitlab|gitea] [--docker-data-root /home/docker-data]
|
||||
#
|
||||
@@ -77,7 +77,7 @@ done
|
||||
[ -n "$SITE" ] || die "--site is required"
|
||||
[[ "$ENV_ID" =~ ^env-(dev|qa|stage|prod)-[0-9]{2,3}$|^(dev-env-2|prod-cedar)$ ]] || die "env id $ENV_ID is not env-<tier>-<nn>"
|
||||
SITE="${SITE,,}"
|
||||
[[ "$SITE" =~ ^(cbs|pdx)$ ]] || die "site must be cbs|pdx"
|
||||
[[ "$SITE" =~ ^(fmt|cbs|pdx|roam)$ ]] || die "site must be fmt|cbs|pdx|roam (tenancy issues fmt|pdx|roam; cbs = the deprecated alias of fmt)"
|
||||
[[ "$TRANSPORT" =~ ^(sdk|proxy|system)$ ]] || die "transport must be sdk|proxy|system"
|
||||
[[ "$SOURCE" =~ ^(gitlab|gitea)$ ]] || die "source must be gitlab|gitea"
|
||||
# never let the token leak through xtrace / the environment of children
|
||||
@@ -219,10 +219,14 @@ install -d -m 0700 -o monky-deployd -g monky-deployd /var/lib/monky-deployd
|
||||
# window before the agent's next login and hosts where the file has another group.
|
||||
# A default ACL on the directory carries the grant onto a freshly created identity file.
|
||||
if getent group ziti >/dev/null; then usermod -a -G ziti monky-deployd || true; fi
|
||||
setfacl -m u:monky-deployd:r "$IDENTITY"
|
||||
setfacl -m u:monky-deployd:rx "$IDENTITY_DIR"
|
||||
setfacl -d -m u:monky-deployd:r "$IDENTITY_DIR" 2>/dev/null || true
|
||||
setfacl -m u:monky-deployd:x /opt/openziti/etc 2>/dev/null || true
|
||||
# The grant must OUTLIVE the tunneller: ziti-edge-tunnel re-creates the identity file on every
|
||||
# controller config update with mode 0600, which sets the ACL mask to --- and defeats both the
|
||||
# named-user entry and the ziti-group read (env-dev-08, 2026-09-11..13: two days of "identity is
|
||||
# not readable" ticks while the tunnel was healthy). identity-acl.sh re-applies the entries and the
|
||||
# mask; the .path unit re-runs it whenever the directory changes.
|
||||
/usr/share/monky-deployd/identity-acl.sh "$IDENTITY_DIR"
|
||||
systemctl enable --now monky-deployd-identity-acl.path 2>/dev/null || true
|
||||
if [ -n "$BAO_CA" ]; then
|
||||
install -m 0644 "$BAO_CA" "$ETC/openbao-ca.pem"
|
||||
fi
|
||||
|
||||
@@ -33,6 +33,14 @@ contents:
|
||||
dst: /usr/lib/systemd/system/monky-deployd.timer
|
||||
- src: ./packaging/systemd/monky-deployd-proxy.service
|
||||
dst: /usr/lib/systemd/system/monky-deployd-proxy.service
|
||||
- src: ./packaging/systemd/monky-deployd-identity-acl.path
|
||||
dst: /usr/lib/systemd/system/monky-deployd-identity-acl.path
|
||||
- src: ./packaging/systemd/monky-deployd-identity-acl.service
|
||||
dst: /usr/lib/systemd/system/monky-deployd-identity-acl.service
|
||||
- src: ./packaging/bin/identity-acl.sh
|
||||
dst: /usr/share/monky-deployd/identity-acl.sh
|
||||
file_info:
|
||||
mode: 0755
|
||||
- src: ./packaging/monky-deployd.sysusers
|
||||
dst: /usr/lib/sysusers.d/monky-deployd.conf
|
||||
- src: ./packaging/monky-deployd.tmpfiles
|
||||
|
||||
@@ -18,6 +18,9 @@ if getent group docker >/dev/null; then usermod -a -G docker monky-deployd || tr
|
||||
# POSIX ACL granting the agent read — group membership is the grant that survives it.
|
||||
# (env-dev-08, 2026-09-09: the agent went from applied to "no intercept" 6 minutes after a refresh.)
|
||||
if getent group ziti >/dev/null; then usermod -a -G ziti monky-deployd || true; fi
|
||||
# ...and group membership does NOT survive it either once the rewrite lands with mode 0600 (the ACL
|
||||
# mask goes to ---). Re-apply the grant now and on every directory change (0.1.10, deployd#3 beat).
|
||||
[ -x /usr/share/monky-deployd/identity-acl.sh ] && /usr/share/monky-deployd/identity-acl.sh /opt/openziti/etc/identities || true
|
||||
# the venv is relocatable only to the path it was built at; refuse a broken interpreter early
|
||||
/opt/monky-deployd/venv/bin/python -c 'import monky_deployd' || { echo "monky-deployd: venv unusable (python3 mismatch?)" >&2; exit 1; }
|
||||
if [ -d /run/systemd/system ]; then
|
||||
@@ -26,5 +29,7 @@ if [ -d /run/systemd/system ]; then
|
||||
# An UPGRADE is different — the timer is already enabled and must keep running, so restart the
|
||||
# long-lived proxy unit onto the new code. `try-restart` is a no-op when it is not running.
|
||||
systemctl try-restart monky-deployd-proxy.service 2>/dev/null || true
|
||||
# an UPGRADE of a box that already has its config: arm the identity-ACL watcher
|
||||
if [ -s /etc/monky-deployd/config.yaml ]; then systemctl enable --now monky-deployd-identity-acl.path 2>/dev/null || true; fi
|
||||
fi
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Re-grant monky-deployd read access when the ziti identity directory changes
|
||||
Documentation=file:/usr/share/doc/monky-deployd/OPERATIONS.md
|
||||
|
||||
[Path]
|
||||
PathChanged=/opt/openziti/etc/identities
|
||||
PathModified=/opt/openziti/etc/identities
|
||||
Unit=monky-deployd-identity-acl.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=Re-grant monky-deployd read access to the ziti identity file(s)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/share/monky-deployd/identity-acl.sh /opt/openziti/etc/identities
|
||||
Reference in New Issue
Block a user