Agent-Fassung "freigegeben": die in der Ausrollstufe festgelegte (ADR-0046 Schritt 3)

Für postinstall.sh: liest tuxflotte_agent_commit aus roles/agent/defaults/main.yml
im aktuellen Spiegel-Stand der Stufe des Geräts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-21 09:52:50 +02:00
1 parent 999b197dd5
commit b8f3b25bda
1 file changed
+22 -2
+22 -2
View File
@@ -7431,6 +7431,22 @@ def agent_ansible_archiv(
return FileResponse(archiv, media_type="application/gzip")
def freigegebene_agent_fassung(stufe: str) -> str | None:
"""Commit aus roles/agent/defaults/main.yml im aktuellen Stand der Stufe
(tuxflotte_agent_commit, ADR-0044). None, wenn nicht ermittelbar."""
with _spiegel_lock:
stand = _spiegel_staende.get(stufe, {}).get("commit")
if not stand:
return None
try:
defaults = _spiegel_git("-C", str(SPIEGEL_DIR / f"{stufe}.git"), "show", f"{stand}:roles/agent/defaults/main.yml")
except (subprocess.SubprocessError, OSError):
return None
treffer = re.search(r'^tuxflotte_agent_commit:\s*"([0-9a-f]{40})"', defaults, re.MULTILINE)
return treffer.group(1) if treffer else None
@app.get("/api/v1/agent/fassung/{commit}/{datei}")
def agent_fassung(
commit: str,
@@ -7439,9 +7455,13 @@ def agent_fassung(
x_tuxflotte_geraet: str | None = Header(default=None),
):
"""Eine Datei des Agenten in einer bestimmten Fassung (ADR-0046) - nur
Commits auf dem Hauptzweig von provisioning-agent, nur feste Dateien."""
Commits auf dem Hauptzweig von provisioning-agent, nur feste Dateien.
"freigegeben" statt eines Commits: die Fassung, die die Rolle "agent" in
der Ausrollstufe dieses Geräts festlegt (Neuinstallation, postinstall.sh)."""
_geraet_aus_kopfzeilen(authorization, x_tuxflotte_geraet)
device_id = _geraet_aus_kopfzeilen(authorization, x_tuxflotte_geraet)
if commit == "freigegeben":
commit = freigegebene_agent_fassung(ausrollstufe_fuer_geraet(device_id)) or ""
pfad = SPIEGEL_DIR / "agent.git"
if not re.fullmatch(r"[0-9a-f]{40}", commit) or datei not in AGENT_FASSUNG_DATEIEN or not (pfad / "HEAD").exists():
raise HTTPException(status_code=404, detail="Unbekannte Fassung.")