Inventaire d'instance neutre et configurable (principal / SETOPS_INVENTAIRE)
Le moteur ne code plus en dur inventories/lab|production : un inventaire par instance, détecté de façon rétro-compatible (principal > production > lab) et surchargeable par SETOPS_INVENTAIRE. Makefile (définitions seules, pas les 47 usages), inventory_gui, instancier, config_proxmox, serveurs, applications. Les instances lab/production existantes marchent à l'identique ; les nouvelles adoptent inventories/principal/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
8b3648e9f9
commit
e2b924cedc
7 changed files with 98 additions and 18 deletions
|
|
@ -38,8 +38,24 @@ from inventory_rules import (
|
|||
|
||||
RACINE = Path(__file__).resolve().parents[1]
|
||||
INSTANCE = Path(os.environ.get("SETOPS_INSTANCE") or (RACINE / "instance"))
|
||||
INVENTAIRE_DEFAUT = INSTANCE / "inventories/production/hosts.yml"
|
||||
INVENTAIRE_PRODUCTION = (INSTANCE / "inventories/production/hosts.yml").resolve()
|
||||
|
||||
|
||||
def _inventaire(instance: Path, *noms: str) -> Path:
|
||||
"""Inventaire de l'instance, détection rétro-compatible (premier existant)."""
|
||||
for nom in noms:
|
||||
p = instance / "inventories" / nom / "hosts.yml"
|
||||
if p.exists():
|
||||
return p
|
||||
return instance / "inventories" / noms[0] / "hosts.yml"
|
||||
|
||||
|
||||
# Un seul inventaire par instance (modèle « séparation par instance ») ; on accepte
|
||||
# l'ancien découpage lab/production en rétro-compatibilité. SETOPS_INVENTAIRE force.
|
||||
_force = os.environ.get("SETOPS_INVENTAIRE")
|
||||
INVENTAIRE_DEFAUT = Path(_force) if _force else _inventaire(INSTANCE, "principal", "production")
|
||||
INVENTAIRE_PRODUCTION = INVENTAIRE_DEFAUT.resolve()
|
||||
# Inventaire qui porte la config Proxmox / le clonage (modèle) : lab > principal > production.
|
||||
INVENTAIRE_MODELE = _inventaire(INSTANCE, "lab", "principal", "production")
|
||||
DOSSIER_PLAYBOOKS_GROUPES = RACINE / "playbooks/groupes"
|
||||
FICHIER_DEPENDANCES = RACINE / "docs/dependances-groupes.yml"
|
||||
FICHIER_NOMENCLATURE = INSTANCE / "plan/nomenclature.yml"
|
||||
|
|
@ -49,11 +65,11 @@ FICHIER_DOMAINES = INSTANCE / "plan/domaines.yml"
|
|||
FICHIER_SERVEURS = INSTANCE / "plan/serveurs.yml"
|
||||
|
||||
# Intrants de base (panneau GUI). Cibles d'ecriture possedees par le GUI.
|
||||
# Identite : source UNIQUE partagee par tous les envs (symlink depuis chaque
|
||||
# group_vars/all/). Proxmox : fichier lab (le clonage le lit en dur), cles gerees
|
||||
# mises a jour, les autres cles preservees. Les SECRETS n'y entrent jamais.
|
||||
# Identite : source UNIQUE partagee (symlink depuis group_vars/all/). Proxmox :
|
||||
# group_vars de l'inventaire modele, cles gerees mises a jour, autres preservees.
|
||||
# Les SECRETS n'y entrent jamais.
|
||||
INTRANTS_IDENTITE = INSTANCE / "inventories/partage/intrants-identite.yml"
|
||||
INTRANTS_PROXMOX = INSTANCE / "inventories/lab/group_vars/proxmox.yml"
|
||||
INTRANTS_PROXMOX = INVENTAIRE_MODELE.parent / "group_vars/proxmox.yml"
|
||||
FICHIERS_INTRANTS = {"identite": INTRANTS_IDENTITE, "proxmox": INTRANTS_PROXMOX}
|
||||
|
||||
# (variable, fichier, classe, section, libelle, type)
|
||||
|
|
|
|||
Loading…
Reference in a new issue