54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""Nomme les hotes qui doivent etre DEBOUT avant tous les autres, derives du plan.
|
||
|
|
|
||
|
|
Contrainte d'architecture posee le 2026-08-08 : « une PKI et un DNS fonctionnels avant
|
||
|
|
toute chose ». Sans eux, chaque VM qui monte reclame un certificat a une autorite absente
|
||
|
|
et un nom a un annuaire muet — et l'echec se lit comme un defaut du role, pas comme un
|
||
|
|
defaut d'ordre.
|
||
|
|
|
||
|
|
Les hotes ne sont PAS ecrits : ils se derivent de `applications.<app>.hote`. Deplacer
|
||
|
|
l'autorite dans le plan deplace l'amorcage avec elle.
|
||
|
|
|
||
|
|
python3 scripts/socle_amorcage.py # un nom d'hote par ligne, dans l'ordre
|
||
|
|
"""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import yaml
|
||
|
|
|
||
|
|
RACINE = Path(__file__).resolve().parent.parent
|
||
|
|
|
||
|
|
# L'ordre compte et n'est pas alphabetique : le DNS a besoin d'un certificat, l'autorite
|
||
|
|
# n'a besoin de personne. Elle passe donc devant — c'est la seule dependance reelle
|
||
|
|
# entre les deux.
|
||
|
|
APPLICATIONS = ["step_ca", "powerdns"]
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> int:
|
||
|
|
base = Path(os.environ.get("SETOPS_INSTANCE") or (RACINE / "instance"))
|
||
|
|
plan = base / "plan" / "applications.yml"
|
||
|
|
if not plan.exists():
|
||
|
|
print(f"Plan introuvable : {plan}", file=sys.stderr)
|
||
|
|
return 2
|
||
|
|
apps = (yaml.safe_load(plan.read_text(encoding="utf-8")) or {}).get("applications") or {}
|
||
|
|
|
||
|
|
vus, sortie = set(), []
|
||
|
|
for nom in APPLICATIONS:
|
||
|
|
hote = (apps.get(nom) or {}).get("hote")
|
||
|
|
if not hote:
|
||
|
|
print(f"L'application « {nom} » n'est pas au plan : impossible d'amorcer le "
|
||
|
|
f"socle sans elle.", file=sys.stderr)
|
||
|
|
return 2
|
||
|
|
if hote not in vus: # PKI et DNS peuvent partager un hote
|
||
|
|
vus.add(hote)
|
||
|
|
sortie.append(hote)
|
||
|
|
print("\n".join(sortie))
|
||
|
|
return 0
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
raise SystemExit(main())
|