Files
ansible-tui/deps.py
2025-11-12 23:18:38 +01:00

41 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
import shutil
import subprocess
import sys
from typing import List
REQUIRED_BINARIES = ["ansible", "ssh", "scp"]
def check_dependencies() -> List[str]:
"""Prüft, welche Binaries fehlen."""
missing = []
for binary in REQUIRED_BINARIES:
if shutil.which(binary) is None:
missing.append(binary)
return missing
def install_dependencies(missing: List[str]) -> None:
"""
Versucht, fehlende Pakete über apt zu installieren.
Achtung: sehr Debian/Raspberry-spezifisch bei Bedarf anpassen.
"""
print("Starte Installation der fehlenden Abhängigkeiten...")
cmds = []
if "ansible" in missing:
cmds.append(["sudo", "apt", "update"])
cmds.append(["sudo", "apt", "install", "-y", "ansible"])
if "ssh" in missing or "scp" in missing:
cmds.append(["sudo", "apt", "install", "-y", "openssh-client"])
for cmd in cmds:
print("", " ".join(cmd))
try:
subprocess.run(cmd, check=False)
except Exception as exc:
print(f"Fehler beim Ausführen von {' '.join(cmd)}: {exc}")
print("Abhängigkeiten-Installation abgeschlossen (ggf. Fehlerausgabe oben prüfen).")