This repository has been archived on 2026-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
Set-OPS/scripts/inventory_rules.py

23 lines
749 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""Regles partagees pour les inventaires statiques Set-OPS."""
from __future__ import annotations
from pathlib import Path
GROUPES_OPERATIONNELS_PREFIXES = ("serveurs_", "clients_")
GROUPE_HOTES_ACTIFS = "hotes_actifs"
GROUPE_HOTES_PLANIFIES = "hotes_planifies"
GROUPES_ETAT_HOTE = {GROUPE_HOTES_ACTIFS, GROUPE_HOTES_PLANIFIES}
def est_groupe_operationnel(groupe: str) -> bool:
return groupe.startswith(GROUPES_OPERATIONNELS_PREFIXES)
def groupes_operationnels_connus(enfants: dict, dossier_playbooks: Path) -> list[str]:
groupes = set(enfants)
groupes.update(playbook.stem for playbook in dossier_playbooks.glob("*.yml"))
return sorted(groupe for groupe in groupes if est_groupe_operationnel(groupe))