Nettoyer les doublons ressuscites par la sync de fichiers
Le depot vivait dans un dossier synchronise (Dropbox/Nextcloud) : la sync a ressuscite d'anciens fichiers pluriels supprimes par le renommage au singulier, et un git add -A les a recommittes. Retire : - 6 group_vars pluriels (serveurs_*, clients_pki) ; - 7 playbooks de groupes pluriels ; - 1 'applications (conflicted copy ...).py'. Les vrais fichiers au singulier existent tous. Valide : ansible-lint 0 echec, diff vide, inventaire-verifier, syntax-check de tous les playbooks. La sync a ete desactivee pour le repertoire des depots (cause racine). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
67950349e7
commit
c61db907c9
14 changed files with 0 additions and 319 deletions
|
|
@ -1,11 +0,0 @@
|
|||
---
|
||||
# Conformite PKI cliente (tout hote devant une identite machine).
|
||||
|
||||
client_pki_ca_url: "https://infra-pki-01.chezlepro.internal:8443"
|
||||
client_pki_provisioner: "admin@chezlepro.internal"
|
||||
|
||||
# Secrets OBLIGATOIRES, a fournir via Ansible Vault avant tout deploiement reel :
|
||||
# client_pki_ca_fingerprint: "{{ vault_step_ca_fingerprint }}"
|
||||
# client_pki_provisioner_password: "{{ vault_step_ca_provisioner_password }}"
|
||||
# Le provisioner password est PARTAGE avec serveur_step_ca : le placer dans un
|
||||
# vault partage (ex. group_vars/all/) lisible par les deux groupes.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
# Conformite supervision Icinga (mon-01, VLAN 14).
|
||||
|
||||
serveur_icinga_db_host: "10.1.13.11" # data-01 (serveur_postgresql)
|
||||
|
||||
# Secret BD OBLIGATOIRE, a fournir via Ansible Vault (partage avec serveur_postgresql) :
|
||||
# vault_bd_icingadb: "..."
|
||||
# A placer dans un vault partage (ex. group_vars/all/) lisible par les deux groupes.
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
---
|
||||
# Conformite Keycloak (idm-01, VLAN 12).
|
||||
|
||||
serveur_keycloak_hostname: "keycloak.chezlepro.internal"
|
||||
serveur_keycloak_db_host: "10.1.13.11" # data-01 (serveur_postgresql)
|
||||
|
||||
# Secrets OBLIGATOIRES, a fournir via Ansible Vault avant tout deploiement reel :
|
||||
# - serveur_keycloak_admin_password: "{{ vault_keycloak_admin }}" (admin bootstrap)
|
||||
# - vault_bd_keycloak: "..." (mot de passe BD, partage avec serveur_postgresql)
|
||||
# Convertir en dossier group_vars/serveur_keycloak/ avec main.yml (clair) + vault.yml (chiffre).
|
||||
# Le secret BD (vault_bd_keycloak) doit etre lisible aussi par serveur_postgresql
|
||||
# (placer dans un vault partage, ex. group_vars/all/).
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
# Conformite nginx / edge (infra-edge-01, VLAN 11).
|
||||
|
||||
# Sites de reverse proxy : a declarer ici quand un service web doit etre publie.
|
||||
# L'amont pointe vers l'IP interne et le port du service (cf. nomenclature).
|
||||
serveur_nginx_sites: []
|
||||
# - nom: forge
|
||||
# domaine: forge.chezlepro.internal
|
||||
# amont: "http://10.1.15.11:3000"
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
# Conformite Redis (data-01, VLAN 13).
|
||||
|
||||
serveur_redis_maxmemory: "256mb"
|
||||
|
||||
# Secret OBLIGATOIRE, a fournir via Ansible Vault avant tout deploiement reel :
|
||||
# serveur_redis_password: "{{ vault_redis }}"
|
||||
# Convertir en dossier group_vars/serveur_redis/ avec main.yml + vault.yml (chiffre).
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
# Conformite AC interne step-ca (infra-pki-01, VLAN 11).
|
||||
|
||||
serveur_step_ca_nom: "Chezlepro Internal CA"
|
||||
serveur_step_ca_adresse: ":8443"
|
||||
serveur_step_ca_acme: true
|
||||
|
||||
# Secrets OBLIGATOIRES, a fournir via Ansible Vault avant tout deploiement reel.
|
||||
# Convertir ce fichier en dossier group_vars/serveur_step_ca/ avec :
|
||||
# main.yml (en clair) :
|
||||
# serveur_step_ca_password: "{{ vault_step_ca_password }}"
|
||||
# serveur_step_ca_provisioner_password: "{{ vault_step_ca_provisioner_password }}"
|
||||
# vault.yml (chiffre ansible-vault) :
|
||||
# vault_step_ca_password: "..."
|
||||
# vault_step_ca_provisioner_password: "..."
|
||||
# Tant qu'ils sont absents, le role refuse de s'executer (assertion explicite).
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe client_journal
|
||||
hosts: client_journal
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- client_journal
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe client_ldap
|
||||
hosts: client_ldap
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- client_ldap
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe serveur_collabora
|
||||
hosts: serveur_collabora
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
tasks:
|
||||
- name: Indiquer que le service Collabora reste à définir
|
||||
ansible.builtin.debug:
|
||||
msg: "Aucun rôle n'est encore associé au groupe serveur_collabora."
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe serveur_grafana
|
||||
hosts: serveur_grafana
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- serveur_grafana
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe serveur_icinga
|
||||
hosts: serveur_icinga
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- serveur_icinga
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe serveur_openldap
|
||||
hosts: serveur_openldap
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- serveur_openldap
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- name: Appliquer le groupe serveur_postgresql
|
||||
hosts: serveur_postgresql
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Vérifier que la cible est Debian
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
fail_msg: "Ce playbook est prévu pour Debian."
|
||||
|
||||
roles:
|
||||
- serveur_postgresql
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Lit et valide le registre des applications Set-OPS (docs/applications.yml)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from inventory_gui import charger_yaml, liste_hotes
|
||||
from inventory_rules import (
|
||||
bases_de_application,
|
||||
chaine_connexion,
|
||||
charger_applications,
|
||||
charger_bases_donnees,
|
||||
charger_domaines,
|
||||
valider_applications,
|
||||
)
|
||||
|
||||
RACINE = Path(__file__).resolve().parents[1]
|
||||
FICHIER = RACINE / "docs/applications.yml"
|
||||
FICHIER_BASES = RACINE / "docs/bases-donnees.yml"
|
||||
FICHIER_DOMAINES = RACINE / "docs/domaines.yml"
|
||||
INVENTAIRE = RACINE / "inventories/production/hosts.yml"
|
||||
|
||||
# Groupes 'serveurs_*' qui sont des capacites de SOCLE (sur toutes les VM),
|
||||
# pas des applications a part entiere.
|
||||
GROUPES_SOCLE = {"serveur_debian", "serveur_durci"}
|
||||
|
||||
|
||||
def _liste(valeur: str) -> list:
|
||||
return [v.strip() for v in (valeur or "").split(",") if v.strip()]
|
||||
|
||||
|
||||
def ecrire(registre: dict) -> None:
|
||||
entete = (
|
||||
"# Registre des applications Set-OPS (application = entite pivot).\n"
|
||||
"# Edite par make inventaire-ui ou scripts/applications.py.\n"
|
||||
"# Une VM peut porter plusieurs applications ; une base se lie a une application.\n"
|
||||
"---\n"
|
||||
)
|
||||
with FICHIER.open("w", encoding="utf-8") as fichier:
|
||||
fichier.write(entete)
|
||||
yaml.safe_dump({"applications": registre.get("applications", {}) or {}},
|
||||
fichier, default_flow_style=False, sort_keys=False, allow_unicode=True)
|
||||
|
||||
|
||||
def lister(registre: dict, bases: dict) -> None:
|
||||
apps = registre.get("applications", {})
|
||||
if not apps:
|
||||
print("Aucune application declaree.")
|
||||
return
|
||||
for nom, app in apps.items():
|
||||
extras = []
|
||||
if app.get("port"):
|
||||
extras.append(f"port {app['port']}")
|
||||
if app.get("requiert"):
|
||||
extras.append(f"requiert {', '.join(app['requiert'])}")
|
||||
if app.get("expose"):
|
||||
extras.append(f"expose {', '.join(app['expose'])}")
|
||||
suffixe = (" {" + " ; ".join(extras) + "}") if extras else ""
|
||||
print(f"{nom} [groupe {app.get('groupe', '?')}, hote {app.get('hote', '?')}]{suffixe}")
|
||||
for entree in bases_de_application(bases, application=nom,
|
||||
groupe=app.get("groupe"), hote=app.get("hote")):
|
||||
base = entree["base"]
|
||||
portee = base.get("portee", "groupe")
|
||||
print(f" DSN ({portee}/{base.get('usage', '-')}): {chaine_connexion(base, entree['serveur'])}")
|
||||
|
||||
|
||||
def bootstrap(registre_existant: dict) -> dict:
|
||||
"""(Re)genere les applications depuis les appartenances de groupes de l'inventaire.
|
||||
|
||||
Un groupe 'serveurs_*' (hors socle) sur un hote = une application. Les entrees
|
||||
existantes correspondant a un couple (groupe, hote) toujours present sont
|
||||
preservees telles quelles (port / expose / requiert ...).
|
||||
"""
|
||||
existant = registre_existant.get("applications") or {}
|
||||
par_cle = {(a.get("groupe"), a.get("hote")): (cle, a) for cle, a in existant.items()}
|
||||
apps: dict = {}
|
||||
for h in liste_hotes(charger_yaml(INVENTAIRE)):
|
||||
hote = h.get("nom")
|
||||
if not hote:
|
||||
continue
|
||||
for groupe in sorted(h.get("groupes", [])):
|
||||
if not groupe.startswith("serveur_") or groupe in GROUPES_SOCLE:
|
||||
continue
|
||||
garde = par_cle.get((groupe, hote))
|
||||
if garde:
|
||||
apps[garde[0]] = garde[1]
|
||||
continue
|
||||
base = groupe[len("serveur_"):]
|
||||
app_id = base if base not in apps else f"{base}-{hote}"
|
||||
apps[app_id] = {"groupe": groupe, "hote": hote}
|
||||
return {"applications": apps}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Registre des applications Set-OPS.")
|
||||
sub = parser.add_subparsers(dest="commande", required=True)
|
||||
sub.add_parser("lister", help="Affiche les applications et leurs DSN resolus.")
|
||||
sub.add_parser("verifier", help="Valide la coherence du registre.")
|
||||
sub.add_parser("bootstrap", help="(Re)genere applications.yml depuis les groupes de l'inventaire.")
|
||||
|
||||
pa = sub.add_parser("ajouter", help="Ajoute ou met a jour une application.")
|
||||
pa.add_argument("--id", required=True)
|
||||
pa.add_argument("--groupe", required=True)
|
||||
pa.add_argument("--hote", required=True)
|
||||
pa.add_argument("--port", type=int)
|
||||
pa.add_argument("--requiert", default="", help="Applications dont elle depend (separees par virgule).")
|
||||
pa.add_argument("--expose", default="", help="FQDN publics qui la publient (separes par virgule).")
|
||||
|
||||
pr = sub.add_parser("retirer", help="Retire une application.")
|
||||
pr.add_argument("--id", required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
registre = charger_applications(FICHIER)
|
||||
domaines = charger_domaines(FICHIER_DOMAINES)
|
||||
if args.commande == "lister":
|
||||
lister(registre, charger_bases_donnees(FICHIER_BASES))
|
||||
elif args.commande == "verifier":
|
||||
valider_applications(registre, domaines)
|
||||
print("Registre des applications valide.")
|
||||
elif args.commande == "bootstrap":
|
||||
registre = bootstrap(registre)
|
||||
valider_applications(registre, domaines)
|
||||
ecrire(registre)
|
||||
print(f"docs/applications.yml genere depuis l'inventaire ({len(registre['applications'])} applications).")
|
||||
elif args.commande == "ajouter":
|
||||
app = {"groupe": args.groupe, "hote": args.hote}
|
||||
if args.port is not None:
|
||||
app["port"] = args.port
|
||||
if _liste(args.requiert):
|
||||
app["requiert"] = _liste(args.requiert)
|
||||
if _liste(args.expose):
|
||||
app["expose"] = _liste(args.expose)
|
||||
registre["applications"][args.id] = app
|
||||
valider_applications(registre, domaines)
|
||||
ecrire(registre)
|
||||
print(f"Application '{args.id}' enregistree.")
|
||||
elif args.commande == "retirer":
|
||||
registre["applications"].pop(args.id, None)
|
||||
valider_applications(registre, domaines)
|
||||
ecrire(registre)
|
||||
print(f"Application '{args.id}' retiree.")
|
||||
except Exception as exc:
|
||||
print(f"erreur: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in a new issue