From e704e1cc396110591e151461f8bea7bae35d5d73 Mon Sep 17 00:00:00 2001 From: Dan Allaire Date: Tue, 21 Oct 2025 11:09:16 -0400 Subject: [PATCH] =?UTF-8?q?normes=20et=20nomenclature=20mn=C3=A9motechniqu?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/architecture/checklist_reunion.md | 310 +++++ docs/architecture/guide_formation.md | 979 ++++++++++++++++ docs/architecture/nomenclature_v2(1).md | 1033 +++++++++++++++++ docs/architecture/nomenclature_v2.md | 1033 +++++++++++++++++ docs/architecture/readme_package.md | 244 ++++ docs/architecture/resolution_adoption.md | 431 +++++++ docs/architecture/scripts_migration.sh | 1248 +++++++++++++++++++++ docs/architecture/templates_automation.md | 968 ++++++++++++++++ 8 files changed, 6246 insertions(+) create mode 100644 docs/architecture/checklist_reunion.md create mode 100644 docs/architecture/guide_formation.md create mode 100644 docs/architecture/nomenclature_v2(1).md create mode 100644 docs/architecture/nomenclature_v2.md create mode 100644 docs/architecture/readme_package.md create mode 100644 docs/architecture/resolution_adoption.md create mode 100644 docs/architecture/scripts_migration.sh create mode 100644 docs/architecture/templates_automation.md diff --git a/docs/architecture/checklist_reunion.md b/docs/architecture/checklist_reunion.md new file mode 100644 index 0000000..252ea16 --- /dev/null +++ b/docs/architecture/checklist_reunion.md @@ -0,0 +1,310 @@ +# CHECKLIST RÉUNION DE VALIDATION +## Standard de Nomenclature v2.0 +### L'Alliance Boréale + +**Réunion prévue le :** [À définir - Semaine du 11 novembre 2025] +**Durée estimée :** 2h30 (avec pause) +**Lieu :** Visioconférence Matrix + partage d'écran +**Participants requis :** Tous les membres du Cercle Technique + +--- + +## 📋 PRÉPARATION (1-2 semaines avant) + +### Documents à Distribuer + +- [ ] **Standard de Nomenclature v2.0** (PDF + Markdown) + - Envoyé par email + lien forge + - Date limite de lecture : 7 jours avant réunion + +- [ ] **Résolution d'Adoption** (cette résolution) + - Format : PDF signable + - À lire AVANT la réunion + +- [ ] **Guide de Formation** (optionnel, pour référence) + - Lien vers la documentation + +- [ ] **Scripts et Templates** (accès forge) + - Dépôt Git accessible à tous + - Instructions d'installation test + +### Préparation Individuelle des Participants + +**Chaque participant DOIT avant la réunion :** + +- [ ] **Lire** le Standard complet (60 pages, ~2h) + - Prendre des notes + - Identifier questions/objections + +- [ ] **Tester** les scripts sur un environnement de test + - Installer les scripts + - Lancer audit-nomenclature.sh + - Tester validation VMID + +- [ ] **Évaluer** l'impact sur son infrastructure + - Estimer nombre de VMs à migrer + - Identifier les cas complexes + - Calculer la charge de travail + +- [ ] **Préparer** ses questions/objections + - Format écrit préférable + - Soumission avant réunion (optionnel) + +### Préparation du Facilitateur + +- [ ] **Réserver** salle visio Matrix avec enregistrement +- [ ] **Préparer** la présentation (voir section suivante) +- [ ] **Compiler** les questions soumises à l'avance +- [ ] **Tester** le partage d'écran et démo live +- [ ] **Préparer** le template de procès-verbal +- [ ] **Imprimer** la résolution (si signatures physiques) + +### Préparation Technique + +- [ ] **Environnement de démo** opérationnel + - Proxmox de test accessible + - Scripts installés et fonctionnels + - Exemples de VMs conformes/non-conformes + +- [ ] **Documents accessibles** pendant la réunion + - Standard (PDF + lien web) + - Résolution (version modifiable) + - Aide-mémoire (imprimable) + +- [ ] **Outils collaboratifs** prêts + - Pad collaboratif (HedgeDoc/Etherpad) + - Partage d'écran + - Sondage pour vote de consentement + +--- + +## 🎯 ORDRE DU JOUR DÉTAILLÉ + +### INTRODUCTION (10 minutes) + +- [ ] **Accueil** et vérification présences + - Tour de table rapide + - Vérifier quorum (tous les membres requis) + +- [ ] **Rappel du contexte** (5 min) + - Pourquoi ce standard ? + - Historique du projet (août-octobre 2025) + - Objectifs de la réunion + +- [ ] **Présentation de l'ordre du jour** (2 min) + - Timing détaillé + - Pause prévue + - Processus de décision (consentement) + +- [ ] **Règles de la réunion** (3 min) + - Parler à tour de rôle (lever la main) + - Questions après chaque section + - Objections exprimées clairement + - Enregistrement (consentement oral) + +--- + +### PARTIE 1 : PRÉSENTATION DU STANDARD (30 minutes) + +#### A) Vue d'Ensemble (10 min) + +- [ ] **Les 4 piliers** du standard + - VMID mnémotechnique + - Plan d'adressage IP + - Nomenclature VMs + - Nomenclature DNS + +- [ ] **Architecture de référence** + - Espace 10.0.0.0/8 derrière NAT + - Infrastructure vs Tenants + - Couches 1-4 vs 5-8 + +- [ ] **Cohérence totale** + - VMID ↔ IP ↔ Nom ↔ DNS + - Démonstration visuelle + +**Questions/Réponses** (5 min) + +#### B) Spécifications Techniques (15 min) + +- [ ] **Format VMID détaillé** + - Infrastructure : 0CTTII + - Tenant : TTTII + - Exemples concrets + - Validation avec validate-vmid.sh (DÉMO) + +- [ ] **Plan d'adressage IP** + - Segmentation infrastructure (10.0.0-2.x) + - Allocation tenants (10.0.10.x + expansion) + - Cohérence avec VMID + +- [ ] **Nomenclature complète** + - Noms VMs (infra et tenants) + - DNS interne/fédéré + - Tables de correspondance + +**Questions/Réponses** (10 min) + +#### C) Outillage (5 min) + +- [ ] **6 scripts fournis** + - audit-nomenclature.sh (DÉMO rapide) + - migrate-vm.sh (montrer le workflow) + - Autres scripts (présentation rapide) + +- [ ] **Templates Ansible/Terraform** + - Structure des modules + - Exemples d'utilisation + +**Questions/Réponses** (5 min) + +--- + +### PAUSE (10 minutes) ☕ + +--- + +### PARTIE 2 : IMPACTS ET MISE EN ŒUVRE (25 minutes) + +#### A) Impact sur Chaque Membre (15 min) + +**Tour de table - chaque membre présente :** + +- [ ] **Chezlepro** (5 min) + - Nombre de VMs à migrer + - Cas complexes identifiés + - Charge de travail estimée + - Questions spécifiques + +- [ ] **Nuage Libre** (5 min) + - Idem + +- [ ] **TechnoLibre** (5 min) + - Idem + +#### B) Plan de Migration (10 min) + +- [ ] **Timeline proposée** + - Formation : 1er décembre 2025 + - Nouveaux déploiements : 1er janvier 2026 + - Migration complète : 31 décembre 2026 + +- [ ] **Ressources allouées** + - Formation (30h Banque de Temps) + - Support technique (20h) + - Budget (0 $ si possible) + +- [ ] **Métriques de succès** + - Taux de conformité cible + - Indicateurs de suivi + +**Questions/Réponses** (10 min) + +--- + +### PARTIE 3 : DISCUSSION ET OBJECTIONS (30 minutes) + +#### A) Questions Générales (10 min) + +- [ ] **Clarifications techniques** + - Répondre aux questions restantes + - Démonstrations supplémentaires si nécessaire + +- [ ] **Concerns opérationnels** + - Faisabilité + - Charge de travail + - Ressources + +#### B) Identification des Objections (20 min) + +**Process sociocratique :** + +- [ ] **Tour de table** : Chaque membre exprime ses objections + - "Qu'est-ce qui rendrait l'adoption de ce standard **nuisible** ?" + - Prendre note de TOUTES les objections + +- [ ] **Catégorisation** des objections + - Bloquantes (rendent l'adoption nuisible) + - Non-bloquantes (améliorations souhaitables) + +- [ ] **Traitement des objections bloquantes** + - Discussion pour chaque objection + - Recherche de solutions + - Modification du standard si nécessaire + - Ré-évaluation après modification + +--- + +### PARTIE 4 : DÉCISION PAR CONSENTEMENT (20 minutes) + +#### A) Reformulation Finale (5 min) + +- [ ] **Récapitulatif** des modifications apportées +- [ ] **Version finale** du standard à adopter +- [ ] **Lecture de la résolution** d'adoption + +#### B) Tour de Consentement (10 min) + +**Pour chaque membre, poser la question :** + +> "As-tu une objection raisonnable et argumentée qui rendrait l'adoption de ce standard **nuisible** pour L'Alliance ou pour ton organisation ?" + +- [ ] **Chezlepro** : Consentement ? ☐ Oui ☐ Objection + - Si objection : __________________________________________ + +- [ ] **Nuage Libre** : Consentement ? ☐ Oui ☐ Objection + - Si objection : __________________________________________ + +- [ ] **TechnoLibre** : Consentement ? ☐ Oui ☐ Objection + - Si objection : __________________________________________ + +#### C) Formalisation (5 min) + +**Si consentement de tous :** + +- [ ] **Déclaration officielle** : "Le Standard de Nomenclature v2.0 est adopté" +- [ ] **Date d'adoption** : _________________________ +- [ ] **Signatures** (électroniques ou physiques) +- [ ] **Annonce** : Publication sur Matrix/Forum + +**Si objection bloquante non résolue :** + +- [ ] Reporter la décision +- [ ] Planifier séance de travail supplémentaire +- [ ] Nouvelle réunion de validation (date : _________) + +--- + +### PARTIE 5 : PROCHAINES ÉTAPES (10 minutes) + +**Si adoption réussie :** + +- [ ] **Publication officielle** + - Forge Git (tag v2.0) + - Wiki Alliance Boréale + - Annonce Matrix/Forum + +- [ ] **Désignation responsabilités** + - Gardien du standard : __________________________ + - Responsable formation : __________________________ + - Support technique : __________________________ + +- [ ] **Planification formation** + - Dates des sessions + - Inscription des administrateurs + +- [ ] **Premiers audits** + - Chaque membre lance audit initial + - Date limite : __________________________ + +- [ ] **Suivi** + - Réunion de suivi 1 mois après (décembre 2025) + - Rapport mensuel de conformité + +--- + +### CLÔTURE (5 minutes) + +- [ ] **Récapitulatif** de la décision +- [ ] **Remerciements** aux participants +- [ ] **Prochaine \ No newline at end of file diff --git a/docs/architecture/guide_formation.md b/docs/architecture/guide_formation.md new file mode 100644 index 0000000..c4ffb73 --- /dev/null +++ b/docs/architecture/guide_formation.md @@ -0,0 +1,979 @@ +# Guide de Formation - Nomenclature v2.0 +## L'Alliance Boréale + +**Version :** 1.0 +**Date :** 21 octobre 2025 +**Durée :** 2-3 heures (formation complète) +**Public :** Administrateurs systèmes membres de L'Alliance +**Prérequis :** Connaissance Proxmox, bases Linux + +--- + +## Table des Matières + +1. [Introduction et Contexte](#1-introduction-et-contexte) +2. [Module 1 : Comprendre le Standard](#2-module-1-comprendre-le-standard) +3. [Module 2 : VMID Mnémotechnique](#3-module-2-vmid-mnémotechnique) +4. [Module 3 : Plan d'Adressage IP](#4-module-3-plan-dadressage-ip) +5. [Module 4 : Nomenclature VMs et DNS](#5-module-4-nomenclature-vms-et-dns) +6. [Module 5 : Outils Pratiques](#6-module-5-outils-pratiques) +7. [Module 6 : Migration en Pratique](#7-module-6-migration-en-pratique) +8. [Exercices Pratiques](#8-exercices-pratiques) +9. [Aide-Mémoire](#9-aide-mémoire) +10. [Certification](#10-certification) + +--- + +## 1. Introduction et Contexte + +### 1.1 Pourquoi un Standard de Nomenclature ? + +**Problèmes avant le standard :** +- ❌ VMs nommées de façon incohérente (vm1, web-server, test123...) +- ❌ VMIDs attribués au hasard (104, 1523, 999...) +- ❌ IPs non structurées (10.50.100.5, 192.168.1.20...) +- ❌ Impossible de retrouver une ressource rapidement +- ❌ Automatisation difficile (Ansible ne peut pas cibler par pattern) +- ❌ Audit et conformité complexes + +**Bénéfices du standard v2.0 :** +- ✅ Identification immédiate de toute ressource +- ✅ VMID → IP → Nom → DNS (cohérence totale) +- ✅ Automatisation facilitée (scripts, Ansible, Terraform) +- ✅ Onboarding rapide des nouveaux admins +- ✅ Audit simplifié pour labellisation +- ✅ Scalabilité (999 tenants, 99 instances par type) + +### 1.2 Architecture de L'Alliance + +**Rappel : Chaque membre est autonome** +``` +┌─────────────────────────────────────────┐ +│ INTERNET PUBLIC │ +└───────────┬─────────────────────────────┘ + │ + ┌───────┼───────┐ + │ │ │ +┌───▼───┐ ┌─▼───┐ ┌─▼───┐ +│ CZP │ │ NUL │ │ TLI │ ← Chaque membre +│ NAT │ │ NAT │ │ NAT │ derrière NAT +└───┬───┘ └──┬──┘ └──┬──┘ + │ │ │ + │ 10.0.0.0/8 (local, identique partout) + │ = Pas de conflit car isolé + │ + └────────┴───────┴──────→ 172.16.0.0/12 + (fédération via tunnels) +``` + +**Point clé :** Tous les membres utilisent **10.0.0.0/8** localement sans conflit. + +--- + +## 2. Module 1 : Comprendre le Standard + +### 2.1 Les 4 Piliers de la Nomenclature + +``` +┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ +│ VMID │ ←→ │ IP │ ←→ │ Nom VM │ ←→ │ DNS │ +│ 02001 │ │10.0.2.10│ │czp-infra│ │dns.infra│ +│ │ │ │ │-dns-... │ │.czp.ab │ +└─────────┘ └─────────┘ └─────────┘ └─────────┘ +``` + +**Tous ces éléments sont liés !** + +### 2.2 Les Deux Catégories de VMs + +#### **A) Infrastructure Fédéré (Couches 1-4)** +Services propres au membre : +- **Couche 1** : Monitoring matériel +- **Couche 2** : DNS, VPN, Réseau +- **Couche 3** : Stockage (Ceph, NFS, Backups) +- **Couche 4** : Orchestration (Ansible, Git, CI/CD) + +#### **B) Tenants (Couches 5-8)** +VMs des clients hébergés : +- Chaque client = 1 tenant +- Tenant 001, 002, 003... +- Services web, DB, API, workers... + +### 2.3 Vue d'Ensemble du Plan + +``` +10.0.0.0/8 (Espace Interne Membre) +│ +├── 10.0.0.0/24 Management +├── 10.0.1.0/24 Platform Services +├── 10.0.2.0/24 Public DNS +├── 10.0.20.0/22 Reserved Infrastructure +│ +├── 10.0.10.0/23 Tenant Infrastructure +└── 10.0.128.0/17 Expansion (50% du /8) +``` + +--- + +## 3. Module 2 : VMID Mnémotechnique + +### 3.1 Format Infrastructure : `0CTTII` + +``` +0 = Infrastructure (fixe) +C = Couche (1, 2, 3, ou 4) +TT = Type de service (00-99) +II = Instance (01-99) +``` + +**Exemples :** +``` +02001 = 0-2-00-01 + │ │ │ └── Instance 1 + │ │ └───── DNS (type 00) + │ └──────── Couche 2 (Réseau) + └────────── Infrastructure + +04201 = 0-4-20-01 + │ │ │ └── Instance 1 + │ │ └───── Git (type 20) + │ └──────── Couche 4 (Orchestration) + └────────── Infrastructure +``` + +### 3.2 Format Tenant : `TTTII` + +``` +TTT = Tenant ID (001-999) +II = Instance (01-99) +``` + +**Exemples :** +``` +10001 = 100-01 + │ └── Instance 1 + └────── Tenant 001 + +10021 = 100-21 + │ └── Instance 21 (convention: DB) + └────── Tenant 001 + +20001 = 200-01 + │ └── Instance 1 + └────── Tenant 002 +``` + +### 3.3 Table de Référence Rapide + +| Type | VMID | Décodage | Description | +|------|------|----------|-------------| +| Infra | 02001 | Couche 2, DNS, Instance 1 | PowerDNS Master | +| Infra | 02002 | Couche 2, DNS, Instance 2 | PowerDNS Slave 1 | +| Infra | 02101 | Couche 2, VPN, Instance 1 | WireGuard Gateway | +| Infra | 04001 | Couche 4, Ansible, Instance 1 | Ansible Controller | +| Tenant | 10001 | Tenant 001, Instance 1 | Web Frontend | +| Tenant | 10021 | Tenant 001, Instance 21 | Database | +| Tenant | 20001 | Tenant 002, Instance 1 | Web Frontend | + +### 3.4 Exercice 1 : Décodage VMID + +**Décoder ces VMIDs :** +1. 03301 → ? +2. 04201 → ? +3. 30011 → ? + +
+Voir les réponses + +1. **03301** = Infrastructure, Couche 3 (Stockage), Type 30 (Backup), Instance 1 → Proxmox Backup Server +2. **04201** = Infrastructure, Couche 4 (Orchestration), Type 20 (Git), Instance 1 → Forgejo +3. **30011** = Tenant 003, Instance 11 → Backend API tenant 003 + +
+ +### 3.5 Exercice 2 : Choix VMID + +**Quel VMID pour :** +1. Un nouveau DNS Slave (3ème) ? +2. La 1ère VM web du tenant 005 ? +3. Un nouveau CI/CD runner (2ème) ? + +
+Voir les réponses + +1. **02003** (Couche 2, DNS type 00, Instance 3) +2. **50001** (Tenant 005, Instance 01) +3. **04102** (Couche 4, CI type 10, Instance 2) + +
+ +--- + +## 4. Module 3 : Plan d'Adressage IP + +### 4.1 Segmentation Infrastructure + +``` +10.0.0.0/24 → Management + .1 → Gateway + .10-.50 → Hyperviseurs Proxmox + .100-.200 → Monitoring + +10.0.1.0/24 → Platform Services + .10 → Ansible (04001) + .20 → Git (04201) + .30 → DB Platform (04301) + .40 → API Admin (04401) + +10.0.2.0/24 → Public DNS + .10 → DNS Master (02001) + .11 → DNS Slave 1 (02002) + .12 → DNS Slave 2 (02003) + .20 → VPN Gateway (02101) +``` + +### 4.2 Allocation Tenants + +**Stratégie simple :** +``` +10.0.10.0-99 → Tenant 001 +10.0.10.100-199 → Tenant 002 +10.0.11.0-99 → Tenant 003 +... +``` + +**Ou avec IPAM automatique** (script allocate-ip.sh) + +### 4.3 Exercice 3 : Allocation IP + +**Quelle IP pour :** +1. Un nouveau PowerDNS Slave 3 ? +2. La 2ème VM web du tenant 001 ? +3. Un 2ème Ansible Controller ? + +
+Voir les réponses + +1. **10.0.2.12** (Segmentation DNS : 10.0.2.0/24) +2. **10.0.10.2** (Tenant 001 : 10.0.10.0-99) +3. **10.0.1.11** (Platform Services : 10.0.1.0/24) + +
+ +--- + +## 5. Module 4 : Nomenclature VMs et DNS + +### 5.1 Format Nom VM Infrastructure + +``` +-infra--- + +Exemples: +czp-infra-dns-master-prod-01 +czp-infra-vpn-gateway-prod-01 +czp-infra-ansible-ctrl-prod-01 +nul-infra-git-forgejo-prod-01 +``` + +### 5.2 Format Nom VM Tenant + +``` +-t--- + +Exemples: +czp-t001-web-prod-01 +czp-t001-db-postgres-prod-01 +czp-t002-api-fastapi-prod-01 +``` + +### 5.3 Format DNS + +**Infrastructure :** +``` +.infra..alliance-boreale.ca + +Exemples: +dns-master.infra.czp.alliance-boreale.ca +ansible.infra.czp.alliance-boreale.ca +``` + +**Tenant :** +``` +.t..alliance-boreale.ca + +Exemples: +web.t001.czp.alliance-boreale.ca +db.t001.czp.alliance-boreale.ca +``` + +### 5.4 Exercice 4 : Construction Complète + +**Pour un nouveau DNS Slave 3 chez Chezlepro :** +- VMID : ? +- IP : ? +- Nom VM : ? +- DNS : ? + +
+Voir les réponses + +- **VMID :** 02003 +- **IP :** 10.0.2.12 +- **Nom VM :** czp-infra-dns-slave3-prod-01 +- **DNS :** dns-slave3.infra.czp.alliance-boreale.ca + +
+ +--- + +## 6. Module 5 : Outils Pratiques + +### 6.1 Installation + +```bash +# Télécharger les scripts +cd /tmp +wget https://forge.alliance-boreale.ca/tools/scripts-nomenclature-v2.tar.gz +tar xzf scripts-nomenclature-v2.tar.gz + +# Installer +sudo bash install-nomenclature-tools.sh +``` + +### 6.2 Configuration + +```bash +# Éditer la configuration +sudo nano /etc/alliance-boreale/nomenclature.conf + +# Contenu: +MEMBER_ID="czp" +DNS_DOMAIN="alliance-boreale.ca" +``` + +### 6.3 Utilisation des Scripts + +#### **1. Audit de Conformité** +```bash +# Audit complet +audit-nomenclature.sh + +# Résultat attendu +✅ CONFORME | VMID: 02001 | Nom: czp-infra-dns-master-prod-01 +❌ NON CONFORME | VMID: 104 | Nom: old-vm +``` + +#### **2. Génération DNS** +```bash +# Générer zone file +generate-dns-records.sh > dns-records.zone + +# Aperçu +dns-master.infra.czp.alliance-boreale.ca. IN A 10.0.2.10 +``` + +#### **3. Validation VMID** +```bash +# Valider un VMID +validate-vmid.sh 02001 + +# Résultat +✅ VMID VALIDE +Type: Infrastructure +Couche: 2 +``` + +#### **4. Migration VM** +```bash +# Simulation +DRY_RUN=true migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 + +# Migration réelle +migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 +``` + +### 6.4 Exercice 5 : Utilisation des Scripts + +**Tâches à réaliser :** +1. Installer les scripts sur votre Proxmox +2. Exécuter un audit de conformité +3. Valider le VMID 02001 +4. Générer les enregistrements DNS + +--- + +## 7. Module 6 : Migration en Pratique + +### 7.1 Workflow de Migration Complet + +``` +┌─────────────────┐ +│ 1. AUDIT │ → Identifier VMs non conformes +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 2. PLANIFICATION│ → Déterminer nouveaux VMID/IP/noms +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 3. BACKUP │ → Sauvegarder toutes les VMs +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 4. MIGRATION │ → Migrer par lots (5-10 VMs) +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 5. VALIDATION │ → Vérifier conformité +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 6. DOCUMENTATION│ → Mettre à jour DNS/Inventaire +└────────┬────────┘ + │ +┌────────▼────────┐ +│ 7. NETTOYAGE │ → Supprimer anciennes VMs +└─────────────────┘ +``` + +### 7.2 Exemple de Migration Pas-à-Pas + +**Scénario :** Migrer une vieille VM web (VMID 104) vers le standard + +#### **Étape 1 : État Actuel** +```bash +# Informations actuelles +VMID: 104 +Nom: old-vm-web +IP: 10.50.100.5 +``` + +#### **Étape 2 : Déterminer Nouveaux Attributs** +```bash +# Cette VM est le web du tenant 001 +# Nouveaux attributs: +VMID: 10001 (Tenant 001, Instance 01) +IP: 10.0.10.1 (Première IP tenant 001) +Nom: czp-t001-web-prod-01 +DNS: web.t001.czp.alliance-boreale.ca +``` + +#### **Étape 3 : Validation** +```bash +# Vérifier VMID +validate-vmid.sh 10001 +# ✅ VMID VALIDE + +# Vérifier IP disponible +allocate-ip.sh 001 +# ✅ IP DISPONIBLE: 10.0.10.1 +``` + +#### **Étape 4 : Backup** +```bash +# Créer snapshot +vzdump 104 --mode snapshot --compress zstd +``` + +#### **Étape 5 : Migration Simulation** +```bash +# Test en dry-run +DRY_RUN=true migrate-vm.sh 104 10001 \ + czp-t001-web-prod-01 10.0.10.1 + +# Vérifier la sortie +``` + +#### **Étape 6 : Migration Réelle** +```bash +# Exécuter migration +migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 + +# Le script fait: +# 1. Backup +# 2. Arrêt VM +# 3. Clone vers nouveau VMID +# 4. Config nouvelle IP +# 5. Démarrage +``` + +#### **Étape 7 : Post-Migration** +```bash +# 1. Se connecter à la VM +ssh root@10.0.10.1 + +# 2. Vérifier et ajuster l'IP dans la VM +nano /etc/network/interfaces +# Changer vers 10.0.10.1/24 + +# 3. Redémarrer réseau +systemctl restart networking + +# 4. Tester connectivité +ping 10.0.0.1 +``` + +#### **Étape 8 : DNS et Inventaire** +```bash +# Ajouter DNS +echo "web.t001.czp.alliance-boreale.ca. IN A 10.0.10.1" >> /etc/bind/zones/... + +# Régénérer inventaire +generate-inventory.sh + +# Tester avec Ansible +ansible web.t001.czp.alliance-boreale.ca -m ping +``` + +#### **Étape 9 : Validation Finale** +```bash +# Audit +audit-nomenclature.sh | grep 10001 +# ✅ CONFORME | VMID: 10001 + +# Une fois validé (quelques jours), supprimer ancienne VM +qm destroy 104 +``` + +### 7.3 Checklist de Migration + +``` +AVANT: +□ Backup complet créé +□ Fenêtre de maintenance planifiée +□ Nouveaux attributs validés (VMID, IP, nom) +□ Plan de rollback documenté +□ Équipe informée + +PENDANT: +□ Migration exécutée (script) +□ VM démarre correctement +□ IP configurée dans la VM +□ Connectivité réseau OK +□ Services applicatifs fonctionnels + +APRÈS: +□ DNS créé +□ Inventaire Ansible mis à jour +□ Monitoring configuré +□ Documentation à jour +□ Tests de régression OK +□ Ancienne VM supprimée (après validation) +``` + +--- + +## 8. Exercices Pratiques + +### Exercice 6 : Planification Migration + +**Vous avez ces VMs à migrer :** + +| VMID | Nom Actuel | IP Actuelle | Type | +|------|------------|-------------|------| +| 100 | dns-server | 192.168.1.10 | DNS Master | +| 105 | web1 | 10.20.30.5 | Web Tenant A | +| 106 | db1 | 10.20.30.6 | DB Tenant A | +| 200 | ansible | 10.10.10.5 | Ansible | + +**Complétez le plan de migration :** + +| VMID Actuel | Nouveau VMID | Nouveau Nom | Nouvelle IP | +|-------------|--------------|-------------|-------------| +| 100 | ? | ? | ? | +| 105 | ? | ? | ? | +| 106 | ? | ? | ? | +| 200 | ? | ? | ? | + +
+Voir les réponses + +| VMID Actuel | Nouveau VMID | Nouveau Nom | Nouvelle IP | +|-------------|--------------|-------------|-------------| +| 100 | 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | +| 105 | 10001 | czp-t001-web-prod-01 | 10.0.10.1 | +| 106 | 10021 | czp-t001-db-postgres-prod-01 | 10.0.10.2 | +| 200 | 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | + +
+ +### Exercice 7 : Création Nouvelle Infrastructure + +**Votre membre rejoint L'Alliance. Créez l'infrastructure minimale (Bronze) :** + +**Ressources nécessaires :** +- 1 DNS Master +- 1 Ansible Controller +- 1 Backup Server + +**Complétez :** + +| Service | VMID | Nom VM | IP | DNS | +|---------|------|--------|-----|-----| +| DNS Master | ? | ? | ? | ? | +| Ansible | ? | ? | ? | ? | +| Backup | ? | ? | ? | ? | + +
+Voir les réponses (exemple membre NUL) + +| Service | VMID | Nom VM | IP | DNS | +|---------|------|--------|-----|-----| +| DNS Master | 02001 | nul-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.nul.ab.ca | +| Ansible | 04001 | nul-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.nul.ab.ca | +| Backup | 03301 | nul-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.nul.ab.ca | + +
+ +### Exercice 8 : Déploiement Nouveau Tenant + +**Un nouveau client (Tenant 005) vous demande :** +- 2 VMs web (load balancing) +- 1 API backend +- 1 Database PostgreSQL +- 1 Redis cache + +**Complétez le plan de déploiement :** + +| Service | VMID | Nom VM | IP | +|---------|------|--------|----| +| Web 1 | ? | ? | ? | +| Web 2 | ? | ? | ? | +| API | ? | ? | ? | +| DB | ? | ? | ? | +| Redis | ? | ? | ? | + +
+Voir les réponses + +| Service | VMID | Nom VM | IP | +|---------|------|--------|----| +| Web 1 | 50001 | czp-t005-web-prod-01 | 10.0.10.40 | +| Web 2 | 50002 | czp-t005-web-prod-02 | 10.0.10.41 | +| API | 50011 | czp-t005-api-fastapi-prod-01 | 10.0.10.42 | +| DB | 50021 | czp-t005-db-postgres-prod-01 | 10.0.10.43 | +| Redis | 50031 | czp-t005-cache-redis-prod-01 | 10.0.10.44 | + +**Note :** Convention instance : +- 01-09 : Web/Frontend +- 10-19 : Backend/API +- 20-29 : Databases +- 30-39 : Cache/Queue + +
+ +--- + +## 9. Aide-Mémoire + +### 9.1 Carte de Référence Rapide + +**À imprimer et garder près de votre écran !** + +``` +╔════════════════════════════════════════════════════════╗ +║ NOMENCLATURE v2.0 - AIDE-MÉMOIRE RAPIDE ║ +╠════════════════════════════════════════════════════════╣ +║ ║ +║ FORMAT VMID INFRASTRUCTURE: 0CTTII ║ +║ 0 = Infrastructure ║ +║ C = Couche (1-4) ║ +║ TT = Type (00-99) ║ +║ II = Instance (01-99) ║ +║ ║ +║ FORMAT VMID TENANT: TTTII ║ +║ TTT = Tenant ID (001-999) ║ +║ II = Instance (01-99) ║ +║ ║ +║ PLAN IP INFRASTRUCTURE: ║ +║ 10.0.0.0/24 → Management ║ +║ 10.0.1.0/24 → Platform Services ║ +║ 10.0.2.0/24 → Public DNS ║ +║ 10.0.20.0/22 → Reserved ║ +║ ║ +║ PLAN IP TENANTS: ║ +║ 10.0.10.0/23 → Tenant Infrastructure ║ +║ 10.0.128.0/17 → Expansion ║ +║ ║ +║ NOM VM INFRA: ║ +║ -infra--- ║ +║ Exemple: czp-infra-dns-master-prod-01 ║ +║ ║ +║ NOM VM TENANT: ║ +║ -t--- ║ +║ Exemple: czp-t001-web-prod-01 ║ +║ ║ +║ DNS INFRA: ║ +║ .infra..alliance-boreale.ca ║ +║ ║ +║ DNS TENANT: ║ +║ .t..alliance-boreale.ca ║ +║ ║ +║ SCRIPTS UTILES: ║ +║ audit-nomenclature.sh # Audit conformité ║ +║ validate-vmid.sh # Valider VMID ║ +║ allocate-ip.sh # Allouer IP ║ +║ migrate-vm.sh # Migration ║ +║ ║ +╚════════════════════════════════════════════════════════╝ +``` + +### 9.2 Table des Types de Services + +#### Couche 2 - Réseau +``` +00-09 : DNS (PowerDNS) +10-19 : VPN/WireGuard +20-29 : Routeurs +30-39 : Proxy/HAProxy +``` + +#### Couche 3 - Stockage +``` +00-09 : Ceph Monitors +10-19 : Ceph OSDs +20-29 : NFS +30-39 : Backup (PBS, Borg) +``` + +#### Couche 4 - Orchestration +``` +00-09 : Ansible +10-19 : CI/CD Runners +20-29 : Git (Forgejo) +30-39 : DB Platform +40-49 : API Admin +``` + +#### Instances Tenant +``` +01-09 : Web/Frontend +10-19 : Backend/API +20-29 : Databases +30-39 : Cache/Queue +40-49 : Workers +``` + +### 9.3 Commandes Fréquentes + +```bash +# Lister toutes les VMs +qm list + +# Info VM +qm config + +# Audit conformité +audit-nomenclature.sh + +# Valider VMID +validate-vmid.sh + +# Générer DNS +generate-dns-records.sh > dns.zone + +# Générer inventaire +generate-inventory.sh + +# Migration (simulation) +DRY_RUN=true migrate-vm.sh + +# Allouer IP tenant +allocate-ip.sh +``` + +--- + +## 10. Certification + +### 10.1 Test de Certification + +**Pour valider votre formation, répondez à ces 10 questions :** + +#### Question 1 +Quel est le VMID pour un 2ème DNS Slave en infrastructure ? +- A) 02002 +- B) 20002 +- C) 02102 +- D) 02200 + +#### Question 2 +Quelle IP pour le 1er Ansible Controller ? +- A) 10.0.0.10 +- B) 10.0.1.10 +- C) 10.0.2.10 +- D) 10.0.4.10 + +#### Question 3 +Quel nom pour la 1ère VM web du tenant 003 (membre czp) ? +- A) czp-web-t003-prod-01 +- B) czp-t003-web-prod-01 +- C) czp-t003-prod-web-01 +- D) czp-tenant003-web-01 + +#### Question 4 +Quel DNS pour l'API du tenant 002 (membre nul) ? +- A) api.nul.t002.alliance-boreale.ca +- B) t002-api.nul.alliance-boreale.ca +- C) api.t002.nul.alliance-boreale.ca +- D) api.tenant002.nul.alliance-boreale.ca + +#### Question 5 +Quelle plage IP pour l'infrastructure Platform Services ? +- A) 10.0.0.0/24 +- B) 10.0.1.0/24 +- C) 10.0.2.0/24 +- D) 10.0.10.0/24 + +#### Question 6 +Le VMID 30021 correspond à quoi ? +- A) Infrastructure Couche 3, Type 00, Instance 21 +- B) Tenant 003, Instance 21 +- C) Tenant 300, Instance 21 +- D) Infrastructure Couche 30, Instance 21 + +#### Question 7 +Combien de tenants maximum peut supporter ce standard ? +- A) 99 +- B) 999 +- C) 9999 +- D) Illimité + +#### Question 8 +Quelle commande pour valider un VMID ? +- A) check-vmid.sh +- B) validate-vmid.sh +- C) test-vmid.sh +- D) verify-vmid.sh + +#### Question 9 +Avant une migration, quelle est la PREMIÈRE étape ? +- A) Arrêter la VM +- B) Créer un backup +- C) Changer le VMID +- D) Modifier l'IP + +#### Question 10 +Où sont stockées les allocations IP des tenants ? +- A) /etc/proxmox/ipam.txt +- B) /var/lib/ipam/allocations.txt +- C) /etc/alliance-boreale/ipam.txt +- D) /etc/network/ipam.conf + +### 10.2 Réponses + +
+Cliquer pour voir les réponses + +1. **A** - 02002 (Couche 2, DNS type 00, Instance 2) +2. **B** - 10.0.1.10 (Platform Services) +3. **B** - czp-t003-web-prod-01 +4. **C** - api.t002.nul.alliance-boreale.ca +5. **B** - 10.0.1.0/24 +6. **B** - Tenant 003, Instance 21 (probablement une DB) +7. **B** - 999 tenants (001-999) +8. **B** - validate-vmid.sh +9. **B** - Créer un backup +10. **C** - /etc/alliance-boreale/ipam.txt + +**Score :** +- 10/10 : ✅ Certifié Expert Nomenclature v2.0 +- 8-9/10 : ✅ Certifié avec révision mineure +- 6-7/10 : ⚠️ Révision recommandée +- <6/10 : ❌ Formation à reprendre + +
+ +### 10.3 Exercice Pratique Final + +**Déploiement complet d'un nouveau membre :** + +**Scénario :** Vous êtes le nouvel administrateur de "TechnoLibre" (tli), membre #003 de L'Alliance. Vous devez déployer l'infrastructure minimale Bronze + 1 premier tenant. + +**Livrables attendus :** + +1. **Plan d'infrastructure (3 VMs minimum) :** + - DNS Master + - Ansible Controller + - Backup Server + +2. **Plan tenant 001 (3 VMs) :** + - Web Frontend + - API Backend + - Database PostgreSQL + +3. **Documentation complète pour chaque VM :** + - VMID + - Nom VM + - IP + - DNS + +4. **Scripts de création :** + - Commandes qm create pour chaque VM + - Commandes de configuration réseau + +5. **Zone DNS complète** + +**Créez un document avec tous ces éléments !** + +--- + +## Ressources Supplémentaires + +### Documentation +- **Standard Nomenclature v2.0** : https://docs.alliance-boreale.ca/nomenclature-v2 +- **Scripts** : https://forge.alliance-boreale.ca/tools/nomenclature-scripts +- **Vidéos** : https://video.alliance-boreale.ca/nomenclature + +### Support +- **Email** : technique@alliance-boreale.ca +- **Matrix** : #technique:alliance-boreale.ca +- **Forum** : https://forum.alliance-boreale.ca/c/nomenclature + +### Communauté +- **Partage de configurations** : https://forge.alliance-boreale.ca/configs +- **Retours d'expérience** : https://blog.alliance-boreale.ca/tag/nomenclature + +--- + +## Conclusion + +### Ce que vous avez appris + +✅ Comprendre la philosophie du standard v2.0 +✅ Maîtriser le format VMID mnémotechnique +✅ Connaître le plan d'adressage IP complet +✅ Construire des noms VMs et DNS conformes +✅ Utiliser les scripts de migration et audit +✅ Planifier et exécuter une migration complète + +### Prochaines Étapes + +1. **Pratiquer** sur un environnement de test +2. **Auditer** votre infrastructure actuelle +3. **Planifier** la migration progressive +4. **Documenter** votre plan +5. **Valider** avec le Cercle Technique +6. **Migrer** par lots sur 6-12 mois + +### Engagement + +En tant qu'administrateur certifié Nomenclature v2.0, vous vous engagez à : +- Respecter le standard pour tous nouveaux déploiements +- Participer à la migration progressive de l'existant +- Partager vos retours d'expérience avec la communauté +- Former les nouveaux administrateurs de votre membre + +--- + +**« Une nomenclature maîtrisée = Une infrastructure maîtrisée »** + +--- + +**FIN DU GUIDE DE FORMATION** + +**Version :** 1.0 +**Date :** 21 octobre 2025 +**Licence :** CC-BY-SA 4.0 +**Auteur :** L'Alliance Boréale - Cercle Technique \ No newline at end of file diff --git a/docs/architecture/nomenclature_v2(1).md b/docs/architecture/nomenclature_v2(1).md new file mode 100644 index 0000000..9218b43 --- /dev/null +++ b/docs/architecture/nomenclature_v2(1).md @@ -0,0 +1,1033 @@ +# Standard de Nomenclature v2.0 +## L'Alliance Boréale + +**Version :** 2.0 +**Date :** 21 octobre 2025 +**Statut :** DRAFT - Validation requise par Cercle Technique +**Remplace :** N/A (première version unifiée) +**Auteur :** Daniel Mathieu (Chezlepro) avec assistance Claude +**Licence :** CC-BY-SA 4.0 + +--- + +## Table des Matières + +1. [Introduction](#1-introduction) +2. [Principes Directeurs](#2-principes-directeurs) +3. [Architecture Réseau de Référence](#3-architecture-réseau-de-référence) +4. [Nomenclature VMID (Proxmox)](#4-nomenclature-vmid-proxmox) +5. [Plan d'Adressage IP](#5-plan-dadressage-ip) +6. [Nomenclature VMs (Noms)](#6-nomenclature-vms-noms) +7. [Nomenclature DNS](#7-nomenclature-dns) +8. [Tables de Correspondance](#8-tables-de-correspondance) +9. [Procédures Opérationnelles](#9-procédures-opérationnelles) +10. [Exemples Complets](#10-exemples-complets) +11. [Migration et Adoption](#11-migration-et-adoption) +12. [Annexes](#12-annexes) + +--- + +## 1. Introduction + +### 1.1 Objectif du Document + +Ce standard définit la **nomenclature unifiée** pour l'infrastructure de L'Alliance Boréale, couvrant : +- Identifiants de machines virtuelles (VMID) dans Proxmox +- Plan d'adressage IP interne (10.0.0.0/8) +- Noms de VMs lisibles et structurés +- Noms de domaine DNS internes et fédérés +- Correspondance entre tous ces éléments + +### 1.2 Portée + +Ce standard s'applique à **tous les membres** de L'Alliance Boréale. Chaque membre, opérant derrière son propre NAT/firewall, utilise ce standard dans son espace interne. + +### 1.3 Cohérence avec l'Architecture + +Ce document est **aligné sur** : +- **Plan d'Adressage IP v3** (03-standards-techniques.md) +- **Architecture à 8 Couches** (Charte Fondatrice) +- **Modèle de fédération décentralisée** (chaque membre autonome) + +--- + +## 2. Principes Directeurs + +### 2.1 Mnémotechnique + +Chaque identifiant doit être **immédiatement compréhensible** : +- Le VMID indique la couche et le type de service +- L'adresse IP reflète la fonction +- Le nom DNS est descriptif + +### 2.2 Cohérence Totale + +**Un seul système** lie : +``` +VMID ←→ IP ←→ Nom VM ←→ DNS +``` + +### 2.3 Scalabilité + +Le système supporte : +- Jusqu'à **999 tenants** par membre +- Jusqu'à **99 instances** par type de service +- Expansion future sans refonte + +### 2.4 Isolation et Autonomie + +- Chaque membre utilise **10.0.0.0/8** localement (derrière NAT) +- Pas de conflit entre membres (isolation par firewall) +- VMIDs peuvent être identiques entre membres (Proxmox séparés) + +--- + +## 3. Architecture Réseau de Référence + +### 3.1 Vue Globale + +``` +┌─────────────────────────────────────────────────────────────┐ +│ INTERNET PUBLIC │ +│ • Services exposés (web, email, DNS public) │ +└─────────────────────┬───────────────────────────────────────┘ + │ + ┌─────────────┼─────────────┐ + │ │ │ +┌───────▼──────┐ ┌────▼─────┐ ┌────▼─────┐ +│ Chezlepro │ │ Nuage │ │ Techno │ +│ FIREWALL/NAT │ │ Libre │ │ Libre │ +└───────┬──────┘ └────┬─────┘ └────┬─────┘ + │ │ │ + │ 10.0.0.0/8 │ 10.0.0.0/8 │ 10.0.0.0/8 + │ (local) │ (local) │ (local) + │ │ │ +┌───────▼─────────────┴─────────────▼──────────────────────┐ +│ ESPACE FÉDÉRATIF (172.16.0.0/12) │ +│ • Services accessibles entre membres via tunnels │ +│ • DNS secondaire, monitoring, backups │ +└───────────────────────────────────────────────────────────┘ +``` + +### 3.2 Plan d'Adressage par Membre + +Chaque membre utilise **10.0.0.0/8** selon cette structure : + +``` +┌─────────────────────────────────────────────────────────────┐ +│ 10.0.0.0/8 - ESPACE INTERNE (derrière NAT) │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ INFRASTRUCTURE DU FÉDÉRÉ (Couches 1-4) │ +│ │ +│ 10.0.0.0/24 → Management (254 hôtes) │ +│ 10.0.1.0/24 → Platform Services (254 hôtes) │ +│ 10.0.2.0/24 → Public DNS (254 hôtes) │ +│ 10.0.20.0/22 → Reserved Infrastructure (1 024 hôtes) │ +│ │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ TENANTS (Couches 5-8) │ +│ │ +│ 10.0.10.0/23 → Tenant Infrastructure (512 hôtes) │ +│ 10.0.128.0/17 → Expansion (32 766 hôtes, 50% du /8) │ +│ │ +└─────────────────────────────────────────────────────────────┘ +``` + +--- + +## 4. Nomenclature VMID (Proxmox) + +### 4.1 Principe Général + +Le VMID Proxmox est un **identifiant numérique mnémotechnique** qui encode : +- La zone (Infrastructure ou Tenant) +- La couche (1-4 pour infra, tenant ID pour tenants) +- Le type de service +- L'instance + +### 4.2 Infrastructure Fédéré (VMID 01000-04999) + +**Format : `0CTTII`** + +Où : +- `0` = Infrastructure fédéré (préfixe fixe) +- `C` = Couche (1, 2, 3, ou 4) +- `TT` = Type de service (00-99) +- `II` = Instance (01-99) + +**Plages par Couche :** +``` +01000-01999 → Couche 1 - Physique (monitoring matériel) +02000-02999 → Couche 2 - Réseau (DNS, VPN, routeurs) +03000-03999 → Couche 3 - Stockage (Ceph, NFS, backups) +04000-04999 → Couche 4 - Orchestration (Ansible, Git, CI/CD) +``` + +**Types de Services (TT) :** + +#### Couche 2 - Réseau (02000-02999) +``` +00-09 : DNS (PowerDNS) +10-19 : VPN/WireGuard +20-29 : Routeurs virtuels +30-39 : Proxy/HAProxy +40-49 : Load Balancers +``` + +#### Couche 3 - Stockage (03000-03999) +``` +00-09 : Ceph Monitors +10-19 : Ceph OSDs (si VMs) +20-29 : NFS Servers +30-39 : Backup Servers (PBS, Borg) +40-49 : Object Storage (MinIO) +``` + +#### Couche 4 - Orchestration (04000-04999) +``` +00-09 : Ansible Controllers +10-19 : CI/CD Runners +20-29 : Forgejo/GitLab +30-39 : PostgreSQL Platform +40-49 : FastAPI Platform Admin +50-59 : Artifact Repositories +``` + +**Exemples :** +``` +02001 = Couche 2, DNS (00), Instance 1 → PowerDNS Master +02002 = Couche 2, DNS (00), Instance 2 → PowerDNS Slave 1 +02101 = Couche 2, VPN (10), Instance 1 → WireGuard Gateway +04001 = Couche 4, Ansible (00), Instance 1 → Ansible Controller +04201 = Couche 4, Git (20), Instance 1 → Forgejo +``` + +### 4.3 Tenants (VMID 10000-99999) + +**Format : `TTTII`** + +Où : +- `TTT` = Tenant ID (001-999) +- `II` = Instance dans le tenant (01-99) + +**Plages par Tenant :** +``` +10001-10099 → Tenant 001 (99 VMs max) +20001-20099 → Tenant 002 (99 VMs max) +30001-30099 → Tenant 003 (99 VMs max) +... +99901-99999 → Tenant 999 (99 VMs max) +``` + +**Convention Instance (II) :** +``` +01-09 : Web/Frontend +10-19 : Backend/API +20-29 : Bases de données +30-39 : Cache/Queue +40-49 : Workers/Jobs +50-59 : Monitoring tenant +60-69 : Dev/Staging +70-99 : Usage libre +``` + +**Exemples :** +``` +10001 = Tenant 001, Instance 01 → Web Frontend +10002 = Tenant 001, Instance 02 → Web Frontend HA +10011 = Tenant 001, Instance 11 → Backend API +10021 = Tenant 001, Instance 21 → PostgreSQL + +20001 = Tenant 002, Instance 01 → Web Frontend +20011 = Tenant 002, Instance 11 → Backend +``` + +### 4.4 Plages Réservées + +``` +00000-00999 : Réservé Proxmox système +01000-04999 : Infrastructure Fédéré (Couches 1-4) +05000-09999 : Réservé extension infrastructure +10000-99999 : Tenants (001-999) +``` + +--- + +## 5. Plan d'Adressage IP + +### 5.1 Infrastructure (10.0.0.0 - 10.0.23.255) + +#### 10.0.0.0/24 - Management +``` +10.0.0.1 → Gateway/Firewall principal +10.0.0.10-.50 → Hyperviseurs Proxmox (nodes physiques) +10.0.0.100-.200 → Outils monitoring/admin (Icinga, Grafana) +10.0.0.250-.254 → Réservé administration +``` + +#### 10.0.1.0/24 - Platform Services +``` +10.0.1.10 → Ansible Controller (VMID 04001) +10.0.1.20 → Forgejo Git (VMID 04201) +10.0.1.30 → PostgreSQL Platform (VMID 04301) +10.0.1.40 → FastAPI Platform Admin (VMID 04401) +10.0.1.50 → Dashboard React Platform (VMID 04501) +10.0.1.100-.200 → Autres services plateforme +``` + +#### 10.0.2.0/24 - Public DNS +``` +10.0.2.10 → PowerDNS Master (VMID 02001) +10.0.2.11 → PowerDNS Slave 1 (VMID 02002) +10.0.2.12 → PowerDNS Slave 2 (VMID 02003) +10.0.2.20 → WireGuard Gateway (VMID 02101) +10.0.2.30 → HAProxy (VMID 02301) +10.0.2.100-.200 → Autres services réseau +``` + +#### 10.0.20.0/22 - Reserved Infrastructure +``` +1 024 adresses réservées pour expansion infrastructure future +``` + +### 5.2 Tenants (10.0.10.0 - 10.255.255.255) + +#### 10.0.10.0/23 - Tenant Infrastructure +``` +512 adresses pour VMs des tenants +Allocation dynamique via IPAM +Gestion par FastAPI Platform +``` + +**Stratégie d'Allocation Suggérée :** +``` +10.0.10.0-.99 → Tenant 001 +10.0.10.100-.199 → Tenant 002 +10.0.11.0-.99 → Tenant 003 +... +``` + +#### 10.0.128.0/17 - Expansion Massive +``` +32 766 adresses (50% du /8) +Réservé pour croissance future des tenants +``` + +### 5.3 Formule de Calcul IP (Infrastructure) + +Pour les services d'infrastructure avec VMID `0CTTII` : + +**Si C=2 (DNS/Réseau) :** +``` +IP = 10.0.2.(TT*10 + II) +``` + +**Exemples :** +``` +VMID 02001 → TT=00, II=01 → 10.0.2.(0*10+1) = 10.0.2.1 (mais on utilise .10) +VMID 02101 → TT=10, II=01 → 10.0.2.(10*10+1) = 10.0.2.101 (mais on utilise .20) +``` + +**Note :** La formule est indicative. En pratique, on utilise une allocation manuelle cohérente documentée ci-dessus. + +--- + +## 6. Nomenclature VMs (Noms) + +### 6.1 Infrastructure (Couches 1-4) + +**Format : `-infra---`** + +Où : +- `` = ID court du membre (czp, nul, tli, etc.) +- `infra` = Marqueur infrastructure (fixe) +- `` = Type de service (dns-master, ansible-ctrl, etc.) +- `` = Environnement (prod, stg, dev, test) +- `` = Numéro (01, 02, 03...) + +**Exemples :** +``` +czp-infra-dns-master-prod-01 +czp-infra-dns-slave1-prod-01 +czp-infra-vpn-gateway-prod-01 +czp-infra-ansible-ctrl-prod-01 +czp-infra-git-forgejo-prod-01 +czp-infra-pbs-backup-prod-01 +czp-infra-ceph-mon1-prod-01 +``` + +### 6.2 Tenants (Couches 5-8) + +**Format : `-t---`** + +Où : +- `` = ID court du membre +- `t` = Tenant (t001, t002, t003...) +- `` = Type de service (web, db, api, backend, cache, worker...) +- `` = Environnement (prod, stg, dev) +- `` = Numéro (01, 02...) + +**Exemples :** +``` +czp-t001-web-prod-01 +czp-t001-db-postgres-prod-01 +czp-t001-api-fastapi-prod-01 +czp-t001-backend-prod-01 +czp-t001-cache-redis-prod-01 + +czp-t002-web-prod-01 +czp-t002-app-backend-prod-01 +czp-t002-db-mysql-prod-01 +``` + +### 6.3 Conventions Types + +**Infrastructure :** +``` +dns-master, dns-slave1, dns-slave2 +vpn-gateway, vpn-peer +ansible-ctrl, ci-runner +git-forgejo, git-gitlab +db-platform, api-admin +pbs-backup, borg-backup +ceph-mon, ceph-osd, nfs-server +``` + +**Tenants :** +``` +web, web-nginx, web-apache +db-postgres, db-mysql, db-mariadb +api-fastapi, api-django, backend +cache-redis, cache-memcached +queue-rabbitmq, queue-redis +worker, job-processor +monitoring, logging +``` + +--- + +## 7. Nomenclature DNS + +### 7.1 Infrastructure (Services Fédérés) + +**Format : `.infra..alliance-boreale.ca`** + +Où : +- `` = Nom du service (dns-master, ansible, git...) +- `infra` = Marqueur infrastructure (fixe) +- `` = ID court (czp, nul, tli) +- `alliance-boreale.ca` = Domaine fédéré + +**Exemples :** +``` +dns-master.infra.czp.alliance-boreale.ca → 10.0.2.10 +dns-slave1.infra.czp.alliance-boreale.ca → 10.0.2.11 +vpn.infra.czp.alliance-boreale.ca → 10.0.2.20 +ansible.infra.czp.alliance-boreale.ca → 10.0.1.10 +git.infra.czp.alliance-boreale.ca → 10.0.1.20 +backup.infra.czp.alliance-boreale.ca → 10.0.1.30 +``` + +### 7.2 Tenants + +**Format : `.t..alliance-boreale.ca`** + +Où : +- `` = Nom du service (web, db, api...) +- `t` = Tenant (t001, t002...) +- `` = ID court +- `alliance-boreale.ca` = Domaine fédéré + +**Exemples :** +``` +web.t001.czp.alliance-boreale.ca → 10.0.10.1 +db.t001.czp.alliance-boreale.ca → 10.0.10.2 +api.t001.czp.alliance-boreale.ca → 10.0.10.3 + +web.t002.czp.alliance-boreale.ca → 10.0.10.10 +backend.t002.czp.alliance-boreale.ca → 10.0.10.11 +``` + +### 7.3 DNS Publics (Exposés) + +Pour les services exposés publiquement : +``` +www.tenant-example.com → IP publique (NAT vers 10.0.10.X) +mail.tenant-example.com → IP publique (NAT vers 10.0.10.Y) +``` + +Le DNS interne reste accessible via le domaine `.alliance-boreale.ca` pour la fédération. + +--- + +## 8. Tables de Correspondance + +### 8.1 Infrastructure Complète (Exemple Chezlepro) + +| VMID | Nom VM | IP Interne | DNS | Fonction | +|------|--------|------------|-----|----------| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | PowerDNS Maître | +| 02002 | czp-infra-dns-slave1-prod-01 | 10.0.2.11 | dns-slave1.infra.czp.ab.ca | PowerDNS Esclave 1 | +| 02003 | czp-infra-dns-slave2-prod-01 | 10.0.2.12 | dns-slave2.infra.czp.ab.ca | PowerDNS Esclave 2 | +| 02101 | czp-infra-vpn-gateway-prod-01 | 10.0.2.20 | vpn.infra.czp.ab.ca | WireGuard Gateway | +| 02301 | czp-infra-proxy-haproxy-prod-01 | 10.0.2.30 | proxy.infra.czp.ab.ca | HAProxy Frontend | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | Proxmox Backup Server | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | Ansible Controller | +| 04201 | czp-infra-git-forgejo-prod-01 | 10.0.1.20 | git.infra.czp.ab.ca | Forgejo Git | +| 04301 | czp-infra-db-platform-prod-01 | 10.0.1.30 | db.infra.czp.ab.ca | PostgreSQL Platform | +| 04401 | czp-infra-api-admin-prod-01 | 10.0.1.40 | api.infra.czp.ab.ca | FastAPI Admin | + +### 8.2 Tenants (Exemples) + +| VMID | Nom VM | IP Interne | DNS | Fonction | +|------|--------|------------|-----|----------| +| 10001 | czp-t001-web-prod-01 | 10.0.10.1 | web.t001.czp.ab.ca | Web Frontend T001 | +| 10002 | czp-t001-web-prod-02 | 10.0.10.2 | web.t001.czp.ab.ca | Web Frontend T001 HA | +| 10011 | czp-t001-api-prod-01 | 10.0.10.3 | api.t001.czp.ab.ca | API Backend T001 | +| 10021 | czp-t001-db-postgres-prod-01 | 10.0.10.4 | db.t001.czp.ab.ca | PostgreSQL T001 | +| 20001 | czp-t002-web-prod-01 | 10.0.10.10 | web.t002.czp.ab.ca | Web Frontend T002 | +| 20011 | czp-t002-backend-prod-01 | 10.0.10.11 | backend.t002.czp.ab.ca | Backend T002 | +| 20021 | czp-t002-db-mysql-prod-01 | 10.0.10.12 | db.t002.czp.ab.ca | MySQL T002 | + +--- + +## 9. Procédures Opérationnelles + +### 9.1 Création d'une Nouvelle VM Infrastructure + +**Étapes :** + +1. **Déterminer le VMID** + ``` + - Identifier la couche (2, 3, ou 4) + - Identifier le type de service + - Choisir l'instance disponible + Exemple: DNS Slave 3 → 02003 + ``` + +2. **Calculer l'IP** + ``` + - Consulter la table d'allocation (section 5) + - Exemple: 02003 → 10.0.2.12 + ``` + +3. **Construire le nom VM** + ``` + Format: -infra--- + Exemple: czp-infra-dns-slave3-prod-01 + ``` + +4. **Créer l'entrée DNS** + ``` + Format: .infra..alliance-boreale.ca + Exemple: dns-slave3.infra.czp.alliance-boreale.ca → 10.0.2.12 + ``` + +5. **Créer la VM dans Proxmox** + ```bash + qm create 02003 \ + --name czp-infra-dns-slave3-prod-01 \ + --net0 virtio,bridge=vmbr0,tag=2 \ + --ipconfig0 ip=10.0.2.12/24,gw=10.0.0.1 + ``` + +6. **Documenter** + - Ajouter dans le registre des VMs + - Mettre à jour l'inventaire Ansible + - Ajouter dans le monitoring + +### 9.2 Création d'une Nouvelle VM Tenant + +**Étapes :** + +1. **Allouer un Tenant ID** + ``` + - Consulter le registre des tenants + - Exemple: Prochain disponible = 003 → t003 + ``` + +2. **Déterminer le VMID** + ``` + Format: TTTII + Exemple: Tenant 003, Web → 30001 + ``` + +3. **Allouer une IP** + ``` + - Utiliser IPAM ou allocation manuelle dans 10.0.10.0/23 + - Exemple: 10.0.10.20 + ``` + +4. **Construire le nom VM** + ``` + Format: -t--- + Exemple: czp-t003-web-prod-01 + ``` + +5. **Créer l'entrée DNS** + ``` + Format: .t..alliance-boreale.ca + Exemple: web.t003.czp.alliance-boreale.ca → 10.0.10.20 + ``` + +6. **Créer la VM dans Proxmox** + ```bash + qm create 30001 \ + --name czp-t003-web-prod-01 \ + --net0 virtio,bridge=vmbr0,tag=10 \ + --ipconfig0 ip=10.0.10.20/23,gw=10.0.0.1 + ``` + +### 9.3 Migration d'une VM Existante + +**Pour renommer selon le nouveau standard :** + +1. **Identifier les attributs actuels** + ``` + VMID actuel: 104 + Nom actuel: vm-web-01 + IP actuelle: 10.50.100.5 + ``` + +2. **Déterminer les nouveaux attributs** + ``` + Catégorie: Tenant 001 + Type: Web + → VMID: 10001 + → IP: 10.0.10.1 + → Nom: czp-t001-web-prod-01 + → DNS: web.t001.czp.alliance-boreale.ca + ``` + +3. **Planifier la migration** + ``` + - Fenêtre de maintenance + - Backup complet + - Plan de rollback + ``` + +4. **Exécuter la migration** + ```bash + # Arrêter la VM + qm stop 104 + + # Renommer (si VMID change, recréer) + qm set 104 --name czp-t001-web-prod-01 + + # Changer l'IP (dans la VM) + # Mettre à jour DNS + # Redémarrer + qm start 104 + + # Valider + ``` + +--- + +## 10. Exemples Complets + +### 10.1 Infrastructure Minimale (Bronze) + +**Membre : Chezlepro (czp)** + +| VMID | Nom | IP | DNS | Description | +|------|-----|-----|-----|-------------| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | DNS Maître | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | Orchestration | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | Backups | + +### 10.2 Infrastructure Complète (Or) + +**Membre : Chezlepro (czp)** + +| VMID | Nom | IP | DNS | +|------|-----|-----|-----| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | +| 02002 | czp-infra-dns-slave1-prod-01 | 10.0.2.11 | dns-slave1.infra.czp.ab.ca | +| 02003 | czp-infra-dns-slave2-prod-01 | 10.0.2.12 | dns-slave2.infra.czp.ab.ca | +| 02101 | czp-infra-vpn-gw-nul-prod-01 | 10.0.2.20 | vpn-nul.infra.czp.ab.ca | +| 02102 | czp-infra-vpn-gw-tli-prod-01 | 10.0.2.21 | vpn-tli.infra.czp.ab.ca | +| 02301 | czp-infra-proxy-haproxy-prod-01 | 10.0.2.30 | proxy.infra.czp.ab.ca | +| 03001 | czp-infra-ceph-mon1-prod-01 | 10.0.1.50 | ceph-mon1.infra.czp.ab.ca | +| 03002 | czp-infra-ceph-mon2-prod-01 | 10.0.1.51 | ceph-mon2.infra.czp.ab.ca | +| 03003 | czp-infra-ceph-mon3-prod-01 | 10.0.1.52 | ceph-mon3.infra.czp.ab.ca | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | +| 04101 | czp-infra-ci-runner1-prod-01 | 10.0.1.60 | ci-runner1.infra.czp.ab.ca | +| 04102 | czp-infra-ci-runner2-prod-01 | 10.0.1.61 | ci-runner2.infra.czp.ab.ca | +| 04201 | czp-infra-git-forgejo-prod-01 | 10.0.1.20 | git.infra.czp.ab.ca | +| 04301 | czp-infra-db-platform-prod-01 | 10.0.1.31 | db.infra.czp.ab.ca | +| 04401 | czp-infra-api-admin-prod-01 | 10.0.1.40 | api.infra.czp.ab.ca | +| 04501 | czp-infra-dashboard-react-prod-01 | 10.0.1.41 | dashboard.infra.czp.ab.ca | + +### 10.3 Tenant Multi-Services + +**Tenant 001 - Client "Acme Corp"** + +| VMID | Nom | IP | DNS | Description | +|------|-----|-----|-----|-------------| +| 10001 | czp-t001-web-prod-01 | 10.0.10.1 | web.t001.czp.ab.ca | Frontend Nginx | +| 10002 | czp-t001-web-prod-02 | 10.0.10.2 | web.t001.czp.ab.ca | Frontend HA | +| 10011 | czp-t001-api-fastapi-prod-01 | 10.0.10.3 | api.t001.czp.ab.ca | Backend API | +| 10021 | czp-t001-db-postgres-prod-01 | 10.0.10.4 | db.t001.czp.ab.ca | PostgreSQL 15 | +| 10031 | czp-t001-cache-redis-prod-01 | 10.0.10.5 | cache.t001.czp.ab.ca | Redis Cache | +| 10041 | czp-t001-worker-celery-prod-01 | 10.0.10.6 | worker.t001.czp.ab.ca | Celery Worker | +| 10061 | czp-t001-web-staging-01 | 10.0.10.7 | web-stg.t001.czp.ab.ca | Staging Web | + +### 10.4 Architecture Fédérée (3 Membres) + +**Services DNS exposés entre membres :** + +| Membre | VMID | Nom | IP Interne | DNS Fédéré | IP Fédérée (172.16.x.x) | +|--------|------|-----|------------|------------|-------------------------| +| Chezlepro | 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | 172.16.1.10 | +| Nuage Libre | 02001 | nul-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.nul.ab.ca | 172.16.2.10 | +| TechnoLibre | 02001 | tli-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.tli.ab.ca | 172.16.3.10 | + +**Note :** Les VMIDs sont identiques (02001) car chaque membre a son propre Proxmox. Les IPs internes sont identiques (10.0.2.10) car isolées par NAT. Les IPs fédérées (172.16.x.x) sont uniques et routées via tunnels VPN. + +--- + +## 11. Migration et Adoption + +### 11.1 Stratégie de Migration + +**Phase 1 : Documentation (Semaine 1-2)** +- [ ] Valider ce standard avec le Cercle Technique +- [ ] Obtenir le consentement de tous les membres actuels +- [ ] Publier dans la documentation officielle +- [ ] Former les administrateurs de chaque membre + +**Phase 2 : Nouveaux Déploiements (Semaine 3+)** +- [ ] Toute nouvelle VM doit suivre ce standard +- [ ] Utiliser les templates Ansible/Terraform mis à jour +- [ ] Documenter dans le registre + +**Phase 3 : Migration Progressive (Mois 2-6)** +- [ ] Inventorier toutes les VMs existantes +- [ ] Prioriser par criticité (services critiques en dernier) +- [ ] Planifier fenêtres de maintenance +- [ ] Migrer par lots (5-10 VMs à la fois) +- [ ] Valider après chaque lot + +**Phase 4 : Consolidation (Mois 7-12)** +- [ ] Vérifier conformité à 100% +- [ ] Mettre à jour toute la documentation +- [ ] Former les nouveaux membres sur ce standard + +### 11.2 Outils de Migration + +**Script d'Audit :** +```bash +#!/bin/bash +# audit-nomenclature.sh +# Vérifie la conformité des VMs au standard v2.0 + +for vmid in $(qm list | awk '{print $1}' | grep -v VMID); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,]*\).*/\1/') + + echo "VMID: $vmid | Nom: $name | IP: $ip" + + # Vérifier conformité VMID + if [[ ! $vmid =~ ^(0[1-4][0-9]{3}|[1-9][0-9]{4})$ ]]; then + echo " ⚠️ VMID non conforme" + fi + + # Vérifier conformité nom + if [[ ! $name =~ ^[a-z]+-((infra)|(t[0-9]{3}))-[a-z0-9-]+-prod-[0-9]{2}$ ]]; then + echo " ⚠️ Nom non conforme" + fi + + echo "" +done +``` + +**Script de Génération DNS :** +```bash +#!/bin/bash +# generate-dns-records.sh +# Génère les enregistrements DNS à partir de l'inventaire Proxmox + +MEMBER="czp" +DOMAIN="alliance-boreale.ca" + +echo "; Infrastructure DNS Records" +for vmid in $(qm list | grep "infra" | awk '{print $1}'); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,\/]*\).*/\1/') + service=$(echo $name | cut -d'-' -f3-) + + echo "${service}.infra.${MEMBER}.${DOMAIN}. IN A ${ip}" +done + +echo "" +echo "; Tenant DNS Records" +for vmid in $(qm list | grep "\-t[0-9]" | awk '{print $1}'); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,\/]*\).*/\1/') + tenant=$(echo $name | grep -oP 't\d{3}') + service=$(echo $name | cut -d'-' -f3) + + echo "${service}.${tenant}.${MEMBER}.${DOMAIN}. IN A ${ip}" +done +``` + +### 11.3 Checklist de Conformité + +**Pour chaque VM :** +- [ ] VMID respecte le format (0CTTII ou TTTII) +- [ ] Nom VM respecte le format +- [ ] IP cohérente avec la fonction +- [ ] Enregistrement DNS créé et fonctionnel +- [ ] Documenté dans l'inventaire +- [ ] Tags Proxmox appropriés +- [ ] Monitoring configuré + +--- + +## 12. Annexes + +### 12.1 Glossaire + +| Terme | Définition | +|-------|------------| +| **VMID** | Identifiant numérique unique d'une VM dans Proxmox | +| **Fédéré** | Membre de L'Alliance Boréale | +| **Tenant** | Client/organisation hébergé par un membre | +| **Infrastructure Fédéré** | Services propres au membre (couches 1-4) | +| **NAT** | Network Address Translation - isole l'espace 10.0.0.0/8 | +| **Espace Fédératif** | Plage 172.16.0.0/12 routée entre membres via tunnels | + +### 12.2 Références + +- **Document 03** : Standards Techniques (Plan d'Adressage IP v3) +- **Document 01** : Charte Fondatrice (Architecture 8 Couches) +- **Document 07** : Guide d'Intégration Technique +- **Document 14** : Structure YAML du Registraire + +### 12.3 Table de Conversion VMID Legacy → v2.0 + +**Si vous avez des VMs avec anciens VMIDs :** + +| Fonction | VMID Legacy | VMID v2.0 | Justification | +|----------|-------------|-----------|---------------| +| DNS Master | 100 | 02001 | Couche 2, DNS (00), Instance 1 | +| DNS Slave | 101 | 02002 | Couche 2, DNS (00), Instance 2 | +| Ansible | 200 | 04001 | Couche 4, Ansible (00), Instance 1 | +| PostgreSQL | 150 | 04301 | Couche 4, DB Platform (30), Instance 1 | +| Web Tenant 1 | 1001 | 10001 | Tenant 001, Instance 01 | +| DB Tenant 1 | 1002 | 10021 | Tenant 001, Instance 21 (DB) | + +### 12.4 FAQ + +**Q : Que faire si j'ai plus de 99 VMs pour un tenant ?** +R : Augmenter le nombre de chiffres pour l'instance (TTTIII au lieu de TTTII), ou subdiviser en sous-tenants (t001a, t001b). + +**Q : Puis-je utiliser des VMIDs personnalisés ?** +R : Non pour les nouveaux déploiements. Le standard doit être respecté pour la cohérence fédérale. + +**Q : Les VMIDs entre membres peuvent-ils être identiques ?** +R : Oui ! Chaque membre a son propre Proxmox. czp-002 peut avoir VMID 02001, et nul-002 aussi. + +**Q : Comment gérer les environnements dev/staging ?** +R : Utiliser le champ `` dans le nom (prod, stg, dev). L'IP peut être dans un sous-réseau dédié (ex: 10.0.100.0/24 pour staging). + +**Q : Faut-il migrer toutes les VMs immédiatement ?** +R : Non. Migration progressive recommandée sur 6-12 mois. Nouveaux déploiements doivent être conformes immédiatement. + +**Q : Comment documenter les exceptions ?** +R : Dans le registre des VMs avec justification. Exceptions doivent être validées par le Cercle Technique. + +### 12.5 Templates de Documentation + +**Template Fiche VM (YAML) :** +```yaml +vm: + vmid: 02001 + name: czp-infra-dns-master-prod-01 + member: czp-001 + category: infrastructure + layer: 2 + service_type: dns + + network: + ip: 10.0.2.10 + subnet: /24 + gateway: 10.0.0.1 + vlan: 2 + + dns: + internal: dns-master.infra.czp.alliance-boreale.ca + federated: dns-master.infra.czp.alliance-boreale.ca + + resources: + cpu: 2 + ram: 4096 + disk: 100G + + backup: + enabled: true + schedule: daily + retention: 30d + + monitoring: + enabled: true + checks: + - dns_query + - process_powerdns + - disk_usage + + tags: + - infrastructure + - dns + - critical + - layer-2 +``` + +**Template Entrée Inventaire Ansible :** +```yaml +# inventory/hosts.yml +all: + children: + infrastructure: + children: + layer_2_network: + hosts: + dns-master.infra.czp.alliance-boreale.ca: + ansible_host: 10.0.2.10 + vmid: 02001 + layer: 2 + service: dns-master + + layer_4_orchestration: + hosts: + ansible.infra.czp.alliance-boreale.ca: + ansible_host: 10.0.1.10 + vmid: 04001 + layer: 4 + service: ansible-controller + + tenants: + children: + tenant_001: + hosts: + web.t001.czp.alliance-boreale.ca: + ansible_host: 10.0.10.1 + vmid: 10001 + tenant: 001 + service: web +``` + +--- + +## 13. Validation et Approbation + +### 13.1 Processus de Validation + +**Ce document doit être validé par :** +- [ ] **Cercle Technique** - Validation technique de la nomenclature +- [ ] **Expert DevOps/SRE** - Validation Proxmox et automatisation +- [ ] **Expert Réseau** - Validation plan IP et DNS +- [ ] **Tous les membres actuels** - Consentement pour adoption + +**Timeline :** +- Semaine 1-2 : Revue et commentaires +- Semaine 3 : Intégration des retours +- Semaine 4 : Vote de consentement +- Semaine 5+ : Publication et déploiement + +### 13.2 Critères d'Acceptation + +Pour que ce standard soit adopté : +- ✅ Aucun membre n'a d'objection majeure (principe de consentement) +- ✅ Compatibilité confirmée avec infrastructures existantes +- ✅ Outils de migration validés et testés +- ✅ Documentation complète et claire +- ✅ Formation prévue pour tous les administrateurs + +### 13.3 Versionnage + +**Version actuelle : 2.0 (DRAFT)** + +Historique des versions : +- v2.0 (2025-10-21) : Création initiale - Nomenclature unifiée complète +- v2.1 (future) : Ajustements après retours terrain + +--- + +## 14. Maintenance du Standard + +### 14.1 Révisions + +Ce document sera révisé : +- **Annuellement** (octobre de chaque année) +- **À la demande** si problème majeur détecté +- **Lors d'évolutions** de l'architecture (nouveau plan IP, etc.) + +### 14.2 Propositions de Modification + +Pour proposer une modification : +1. Ouvrir une issue dans le dépôt Git de gouvernance +2. Documenter le problème et la solution proposée +3. Discussion au Cercle Technique (1 réunion minimum) +4. Vote de consentement si impact majeur +5. Publication de la nouvelle version + +### 14.3 Responsable du Document + +**Responsable principal :** Cercle Technique +**Contact :** technique@alliance-boreale.ca +**Dépôt Git :** https://forge.alliance-boreale.ca/standards/nomenclature + +--- + +## 15. Conclusion + +### 15.1 Récapitulatif + +Ce Standard de Nomenclature v2.0 établit : +- ✅ Un système unifié VMID ↔ IP ↔ Nom ↔ DNS +- ✅ Une organisation claire Infrastructure vs Tenants +- ✅ Une scalabilité jusqu'à 999 tenants par membre +- ✅ Une cohérence avec le Plan d'Adressage IP v3 +- ✅ Des procédures opérationnelles claires +- ✅ Une stratégie de migration progressive + +### 15.2 Bénéfices Attendus + +**Pour les Membres :** +- Gestion simplifiée de l'infrastructure +- Onboarding rapide des nouveaux administrateurs +- Automatisation facilitée (Ansible, Terraform) +- Audit et conformité simplifiés + +**Pour L'Alliance :** +- Interopérabilité renforcée +- Documentation homogène +- Support technique facilité +- Crédibilité professionnelle + +### 15.3 Prochaines Étapes + +1. **Validation** : Soumettre au Cercle Technique (semaine du 28 octobre 2025) +2. **Révision** : Intégrer retours (semaine du 4 novembre 2025) +3. **Vote** : Consentement des membres (semaine du 11 novembre 2025) +4. **Publication** : Version finale (15 novembre 2025) +5. **Formation** : Sessions pour administrateurs (décembre 2025) +6. **Déploiement** : Nouveaux projets conformes (janvier 2026) +7. **Migration** : VMs existantes (jan-déc 2026) + +--- + +**« Une nomenclature claire est le fondement d'une infrastructure maîtrisée. »** + +--- + +**FIN DU DOCUMENT** + +**Standard de Nomenclature v2.0 - L'Alliance Boréale** +**© 2025 L'Alliance Boréale - CC-BY-SA 4.0** +**Document préparé avec l'assistance de Claude (Anthropic)** \ No newline at end of file diff --git a/docs/architecture/nomenclature_v2.md b/docs/architecture/nomenclature_v2.md new file mode 100644 index 0000000..9218b43 --- /dev/null +++ b/docs/architecture/nomenclature_v2.md @@ -0,0 +1,1033 @@ +# Standard de Nomenclature v2.0 +## L'Alliance Boréale + +**Version :** 2.0 +**Date :** 21 octobre 2025 +**Statut :** DRAFT - Validation requise par Cercle Technique +**Remplace :** N/A (première version unifiée) +**Auteur :** Daniel Mathieu (Chezlepro) avec assistance Claude +**Licence :** CC-BY-SA 4.0 + +--- + +## Table des Matières + +1. [Introduction](#1-introduction) +2. [Principes Directeurs](#2-principes-directeurs) +3. [Architecture Réseau de Référence](#3-architecture-réseau-de-référence) +4. [Nomenclature VMID (Proxmox)](#4-nomenclature-vmid-proxmox) +5. [Plan d'Adressage IP](#5-plan-dadressage-ip) +6. [Nomenclature VMs (Noms)](#6-nomenclature-vms-noms) +7. [Nomenclature DNS](#7-nomenclature-dns) +8. [Tables de Correspondance](#8-tables-de-correspondance) +9. [Procédures Opérationnelles](#9-procédures-opérationnelles) +10. [Exemples Complets](#10-exemples-complets) +11. [Migration et Adoption](#11-migration-et-adoption) +12. [Annexes](#12-annexes) + +--- + +## 1. Introduction + +### 1.1 Objectif du Document + +Ce standard définit la **nomenclature unifiée** pour l'infrastructure de L'Alliance Boréale, couvrant : +- Identifiants de machines virtuelles (VMID) dans Proxmox +- Plan d'adressage IP interne (10.0.0.0/8) +- Noms de VMs lisibles et structurés +- Noms de domaine DNS internes et fédérés +- Correspondance entre tous ces éléments + +### 1.2 Portée + +Ce standard s'applique à **tous les membres** de L'Alliance Boréale. Chaque membre, opérant derrière son propre NAT/firewall, utilise ce standard dans son espace interne. + +### 1.3 Cohérence avec l'Architecture + +Ce document est **aligné sur** : +- **Plan d'Adressage IP v3** (03-standards-techniques.md) +- **Architecture à 8 Couches** (Charte Fondatrice) +- **Modèle de fédération décentralisée** (chaque membre autonome) + +--- + +## 2. Principes Directeurs + +### 2.1 Mnémotechnique + +Chaque identifiant doit être **immédiatement compréhensible** : +- Le VMID indique la couche et le type de service +- L'adresse IP reflète la fonction +- Le nom DNS est descriptif + +### 2.2 Cohérence Totale + +**Un seul système** lie : +``` +VMID ←→ IP ←→ Nom VM ←→ DNS +``` + +### 2.3 Scalabilité + +Le système supporte : +- Jusqu'à **999 tenants** par membre +- Jusqu'à **99 instances** par type de service +- Expansion future sans refonte + +### 2.4 Isolation et Autonomie + +- Chaque membre utilise **10.0.0.0/8** localement (derrière NAT) +- Pas de conflit entre membres (isolation par firewall) +- VMIDs peuvent être identiques entre membres (Proxmox séparés) + +--- + +## 3. Architecture Réseau de Référence + +### 3.1 Vue Globale + +``` +┌─────────────────────────────────────────────────────────────┐ +│ INTERNET PUBLIC │ +│ • Services exposés (web, email, DNS public) │ +└─────────────────────┬───────────────────────────────────────┘ + │ + ┌─────────────┼─────────────┐ + │ │ │ +┌───────▼──────┐ ┌────▼─────┐ ┌────▼─────┐ +│ Chezlepro │ │ Nuage │ │ Techno │ +│ FIREWALL/NAT │ │ Libre │ │ Libre │ +└───────┬──────┘ └────┬─────┘ └────┬─────┘ + │ │ │ + │ 10.0.0.0/8 │ 10.0.0.0/8 │ 10.0.0.0/8 + │ (local) │ (local) │ (local) + │ │ │ +┌───────▼─────────────┴─────────────▼──────────────────────┐ +│ ESPACE FÉDÉRATIF (172.16.0.0/12) │ +│ • Services accessibles entre membres via tunnels │ +│ • DNS secondaire, monitoring, backups │ +└───────────────────────────────────────────────────────────┘ +``` + +### 3.2 Plan d'Adressage par Membre + +Chaque membre utilise **10.0.0.0/8** selon cette structure : + +``` +┌─────────────────────────────────────────────────────────────┐ +│ 10.0.0.0/8 - ESPACE INTERNE (derrière NAT) │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ INFRASTRUCTURE DU FÉDÉRÉ (Couches 1-4) │ +│ │ +│ 10.0.0.0/24 → Management (254 hôtes) │ +│ 10.0.1.0/24 → Platform Services (254 hôtes) │ +│ 10.0.2.0/24 → Public DNS (254 hôtes) │ +│ 10.0.20.0/22 → Reserved Infrastructure (1 024 hôtes) │ +│ │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ TENANTS (Couches 5-8) │ +│ │ +│ 10.0.10.0/23 → Tenant Infrastructure (512 hôtes) │ +│ 10.0.128.0/17 → Expansion (32 766 hôtes, 50% du /8) │ +│ │ +└─────────────────────────────────────────────────────────────┘ +``` + +--- + +## 4. Nomenclature VMID (Proxmox) + +### 4.1 Principe Général + +Le VMID Proxmox est un **identifiant numérique mnémotechnique** qui encode : +- La zone (Infrastructure ou Tenant) +- La couche (1-4 pour infra, tenant ID pour tenants) +- Le type de service +- L'instance + +### 4.2 Infrastructure Fédéré (VMID 01000-04999) + +**Format : `0CTTII`** + +Où : +- `0` = Infrastructure fédéré (préfixe fixe) +- `C` = Couche (1, 2, 3, ou 4) +- `TT` = Type de service (00-99) +- `II` = Instance (01-99) + +**Plages par Couche :** +``` +01000-01999 → Couche 1 - Physique (monitoring matériel) +02000-02999 → Couche 2 - Réseau (DNS, VPN, routeurs) +03000-03999 → Couche 3 - Stockage (Ceph, NFS, backups) +04000-04999 → Couche 4 - Orchestration (Ansible, Git, CI/CD) +``` + +**Types de Services (TT) :** + +#### Couche 2 - Réseau (02000-02999) +``` +00-09 : DNS (PowerDNS) +10-19 : VPN/WireGuard +20-29 : Routeurs virtuels +30-39 : Proxy/HAProxy +40-49 : Load Balancers +``` + +#### Couche 3 - Stockage (03000-03999) +``` +00-09 : Ceph Monitors +10-19 : Ceph OSDs (si VMs) +20-29 : NFS Servers +30-39 : Backup Servers (PBS, Borg) +40-49 : Object Storage (MinIO) +``` + +#### Couche 4 - Orchestration (04000-04999) +``` +00-09 : Ansible Controllers +10-19 : CI/CD Runners +20-29 : Forgejo/GitLab +30-39 : PostgreSQL Platform +40-49 : FastAPI Platform Admin +50-59 : Artifact Repositories +``` + +**Exemples :** +``` +02001 = Couche 2, DNS (00), Instance 1 → PowerDNS Master +02002 = Couche 2, DNS (00), Instance 2 → PowerDNS Slave 1 +02101 = Couche 2, VPN (10), Instance 1 → WireGuard Gateway +04001 = Couche 4, Ansible (00), Instance 1 → Ansible Controller +04201 = Couche 4, Git (20), Instance 1 → Forgejo +``` + +### 4.3 Tenants (VMID 10000-99999) + +**Format : `TTTII`** + +Où : +- `TTT` = Tenant ID (001-999) +- `II` = Instance dans le tenant (01-99) + +**Plages par Tenant :** +``` +10001-10099 → Tenant 001 (99 VMs max) +20001-20099 → Tenant 002 (99 VMs max) +30001-30099 → Tenant 003 (99 VMs max) +... +99901-99999 → Tenant 999 (99 VMs max) +``` + +**Convention Instance (II) :** +``` +01-09 : Web/Frontend +10-19 : Backend/API +20-29 : Bases de données +30-39 : Cache/Queue +40-49 : Workers/Jobs +50-59 : Monitoring tenant +60-69 : Dev/Staging +70-99 : Usage libre +``` + +**Exemples :** +``` +10001 = Tenant 001, Instance 01 → Web Frontend +10002 = Tenant 001, Instance 02 → Web Frontend HA +10011 = Tenant 001, Instance 11 → Backend API +10021 = Tenant 001, Instance 21 → PostgreSQL + +20001 = Tenant 002, Instance 01 → Web Frontend +20011 = Tenant 002, Instance 11 → Backend +``` + +### 4.4 Plages Réservées + +``` +00000-00999 : Réservé Proxmox système +01000-04999 : Infrastructure Fédéré (Couches 1-4) +05000-09999 : Réservé extension infrastructure +10000-99999 : Tenants (001-999) +``` + +--- + +## 5. Plan d'Adressage IP + +### 5.1 Infrastructure (10.0.0.0 - 10.0.23.255) + +#### 10.0.0.0/24 - Management +``` +10.0.0.1 → Gateway/Firewall principal +10.0.0.10-.50 → Hyperviseurs Proxmox (nodes physiques) +10.0.0.100-.200 → Outils monitoring/admin (Icinga, Grafana) +10.0.0.250-.254 → Réservé administration +``` + +#### 10.0.1.0/24 - Platform Services +``` +10.0.1.10 → Ansible Controller (VMID 04001) +10.0.1.20 → Forgejo Git (VMID 04201) +10.0.1.30 → PostgreSQL Platform (VMID 04301) +10.0.1.40 → FastAPI Platform Admin (VMID 04401) +10.0.1.50 → Dashboard React Platform (VMID 04501) +10.0.1.100-.200 → Autres services plateforme +``` + +#### 10.0.2.0/24 - Public DNS +``` +10.0.2.10 → PowerDNS Master (VMID 02001) +10.0.2.11 → PowerDNS Slave 1 (VMID 02002) +10.0.2.12 → PowerDNS Slave 2 (VMID 02003) +10.0.2.20 → WireGuard Gateway (VMID 02101) +10.0.2.30 → HAProxy (VMID 02301) +10.0.2.100-.200 → Autres services réseau +``` + +#### 10.0.20.0/22 - Reserved Infrastructure +``` +1 024 adresses réservées pour expansion infrastructure future +``` + +### 5.2 Tenants (10.0.10.0 - 10.255.255.255) + +#### 10.0.10.0/23 - Tenant Infrastructure +``` +512 adresses pour VMs des tenants +Allocation dynamique via IPAM +Gestion par FastAPI Platform +``` + +**Stratégie d'Allocation Suggérée :** +``` +10.0.10.0-.99 → Tenant 001 +10.0.10.100-.199 → Tenant 002 +10.0.11.0-.99 → Tenant 003 +... +``` + +#### 10.0.128.0/17 - Expansion Massive +``` +32 766 adresses (50% du /8) +Réservé pour croissance future des tenants +``` + +### 5.3 Formule de Calcul IP (Infrastructure) + +Pour les services d'infrastructure avec VMID `0CTTII` : + +**Si C=2 (DNS/Réseau) :** +``` +IP = 10.0.2.(TT*10 + II) +``` + +**Exemples :** +``` +VMID 02001 → TT=00, II=01 → 10.0.2.(0*10+1) = 10.0.2.1 (mais on utilise .10) +VMID 02101 → TT=10, II=01 → 10.0.2.(10*10+1) = 10.0.2.101 (mais on utilise .20) +``` + +**Note :** La formule est indicative. En pratique, on utilise une allocation manuelle cohérente documentée ci-dessus. + +--- + +## 6. Nomenclature VMs (Noms) + +### 6.1 Infrastructure (Couches 1-4) + +**Format : `-infra---`** + +Où : +- `` = ID court du membre (czp, nul, tli, etc.) +- `infra` = Marqueur infrastructure (fixe) +- `` = Type de service (dns-master, ansible-ctrl, etc.) +- `` = Environnement (prod, stg, dev, test) +- `` = Numéro (01, 02, 03...) + +**Exemples :** +``` +czp-infra-dns-master-prod-01 +czp-infra-dns-slave1-prod-01 +czp-infra-vpn-gateway-prod-01 +czp-infra-ansible-ctrl-prod-01 +czp-infra-git-forgejo-prod-01 +czp-infra-pbs-backup-prod-01 +czp-infra-ceph-mon1-prod-01 +``` + +### 6.2 Tenants (Couches 5-8) + +**Format : `-t---`** + +Où : +- `` = ID court du membre +- `t` = Tenant (t001, t002, t003...) +- `` = Type de service (web, db, api, backend, cache, worker...) +- `` = Environnement (prod, stg, dev) +- `` = Numéro (01, 02...) + +**Exemples :** +``` +czp-t001-web-prod-01 +czp-t001-db-postgres-prod-01 +czp-t001-api-fastapi-prod-01 +czp-t001-backend-prod-01 +czp-t001-cache-redis-prod-01 + +czp-t002-web-prod-01 +czp-t002-app-backend-prod-01 +czp-t002-db-mysql-prod-01 +``` + +### 6.3 Conventions Types + +**Infrastructure :** +``` +dns-master, dns-slave1, dns-slave2 +vpn-gateway, vpn-peer +ansible-ctrl, ci-runner +git-forgejo, git-gitlab +db-platform, api-admin +pbs-backup, borg-backup +ceph-mon, ceph-osd, nfs-server +``` + +**Tenants :** +``` +web, web-nginx, web-apache +db-postgres, db-mysql, db-mariadb +api-fastapi, api-django, backend +cache-redis, cache-memcached +queue-rabbitmq, queue-redis +worker, job-processor +monitoring, logging +``` + +--- + +## 7. Nomenclature DNS + +### 7.1 Infrastructure (Services Fédérés) + +**Format : `.infra..alliance-boreale.ca`** + +Où : +- `` = Nom du service (dns-master, ansible, git...) +- `infra` = Marqueur infrastructure (fixe) +- `` = ID court (czp, nul, tli) +- `alliance-boreale.ca` = Domaine fédéré + +**Exemples :** +``` +dns-master.infra.czp.alliance-boreale.ca → 10.0.2.10 +dns-slave1.infra.czp.alliance-boreale.ca → 10.0.2.11 +vpn.infra.czp.alliance-boreale.ca → 10.0.2.20 +ansible.infra.czp.alliance-boreale.ca → 10.0.1.10 +git.infra.czp.alliance-boreale.ca → 10.0.1.20 +backup.infra.czp.alliance-boreale.ca → 10.0.1.30 +``` + +### 7.2 Tenants + +**Format : `.t..alliance-boreale.ca`** + +Où : +- `` = Nom du service (web, db, api...) +- `t` = Tenant (t001, t002...) +- `` = ID court +- `alliance-boreale.ca` = Domaine fédéré + +**Exemples :** +``` +web.t001.czp.alliance-boreale.ca → 10.0.10.1 +db.t001.czp.alliance-boreale.ca → 10.0.10.2 +api.t001.czp.alliance-boreale.ca → 10.0.10.3 + +web.t002.czp.alliance-boreale.ca → 10.0.10.10 +backend.t002.czp.alliance-boreale.ca → 10.0.10.11 +``` + +### 7.3 DNS Publics (Exposés) + +Pour les services exposés publiquement : +``` +www.tenant-example.com → IP publique (NAT vers 10.0.10.X) +mail.tenant-example.com → IP publique (NAT vers 10.0.10.Y) +``` + +Le DNS interne reste accessible via le domaine `.alliance-boreale.ca` pour la fédération. + +--- + +## 8. Tables de Correspondance + +### 8.1 Infrastructure Complète (Exemple Chezlepro) + +| VMID | Nom VM | IP Interne | DNS | Fonction | +|------|--------|------------|-----|----------| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | PowerDNS Maître | +| 02002 | czp-infra-dns-slave1-prod-01 | 10.0.2.11 | dns-slave1.infra.czp.ab.ca | PowerDNS Esclave 1 | +| 02003 | czp-infra-dns-slave2-prod-01 | 10.0.2.12 | dns-slave2.infra.czp.ab.ca | PowerDNS Esclave 2 | +| 02101 | czp-infra-vpn-gateway-prod-01 | 10.0.2.20 | vpn.infra.czp.ab.ca | WireGuard Gateway | +| 02301 | czp-infra-proxy-haproxy-prod-01 | 10.0.2.30 | proxy.infra.czp.ab.ca | HAProxy Frontend | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | Proxmox Backup Server | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | Ansible Controller | +| 04201 | czp-infra-git-forgejo-prod-01 | 10.0.1.20 | git.infra.czp.ab.ca | Forgejo Git | +| 04301 | czp-infra-db-platform-prod-01 | 10.0.1.30 | db.infra.czp.ab.ca | PostgreSQL Platform | +| 04401 | czp-infra-api-admin-prod-01 | 10.0.1.40 | api.infra.czp.ab.ca | FastAPI Admin | + +### 8.2 Tenants (Exemples) + +| VMID | Nom VM | IP Interne | DNS | Fonction | +|------|--------|------------|-----|----------| +| 10001 | czp-t001-web-prod-01 | 10.0.10.1 | web.t001.czp.ab.ca | Web Frontend T001 | +| 10002 | czp-t001-web-prod-02 | 10.0.10.2 | web.t001.czp.ab.ca | Web Frontend T001 HA | +| 10011 | czp-t001-api-prod-01 | 10.0.10.3 | api.t001.czp.ab.ca | API Backend T001 | +| 10021 | czp-t001-db-postgres-prod-01 | 10.0.10.4 | db.t001.czp.ab.ca | PostgreSQL T001 | +| 20001 | czp-t002-web-prod-01 | 10.0.10.10 | web.t002.czp.ab.ca | Web Frontend T002 | +| 20011 | czp-t002-backend-prod-01 | 10.0.10.11 | backend.t002.czp.ab.ca | Backend T002 | +| 20021 | czp-t002-db-mysql-prod-01 | 10.0.10.12 | db.t002.czp.ab.ca | MySQL T002 | + +--- + +## 9. Procédures Opérationnelles + +### 9.1 Création d'une Nouvelle VM Infrastructure + +**Étapes :** + +1. **Déterminer le VMID** + ``` + - Identifier la couche (2, 3, ou 4) + - Identifier le type de service + - Choisir l'instance disponible + Exemple: DNS Slave 3 → 02003 + ``` + +2. **Calculer l'IP** + ``` + - Consulter la table d'allocation (section 5) + - Exemple: 02003 → 10.0.2.12 + ``` + +3. **Construire le nom VM** + ``` + Format: -infra--- + Exemple: czp-infra-dns-slave3-prod-01 + ``` + +4. **Créer l'entrée DNS** + ``` + Format: .infra..alliance-boreale.ca + Exemple: dns-slave3.infra.czp.alliance-boreale.ca → 10.0.2.12 + ``` + +5. **Créer la VM dans Proxmox** + ```bash + qm create 02003 \ + --name czp-infra-dns-slave3-prod-01 \ + --net0 virtio,bridge=vmbr0,tag=2 \ + --ipconfig0 ip=10.0.2.12/24,gw=10.0.0.1 + ``` + +6. **Documenter** + - Ajouter dans le registre des VMs + - Mettre à jour l'inventaire Ansible + - Ajouter dans le monitoring + +### 9.2 Création d'une Nouvelle VM Tenant + +**Étapes :** + +1. **Allouer un Tenant ID** + ``` + - Consulter le registre des tenants + - Exemple: Prochain disponible = 003 → t003 + ``` + +2. **Déterminer le VMID** + ``` + Format: TTTII + Exemple: Tenant 003, Web → 30001 + ``` + +3. **Allouer une IP** + ``` + - Utiliser IPAM ou allocation manuelle dans 10.0.10.0/23 + - Exemple: 10.0.10.20 + ``` + +4. **Construire le nom VM** + ``` + Format: -t--- + Exemple: czp-t003-web-prod-01 + ``` + +5. **Créer l'entrée DNS** + ``` + Format: .t..alliance-boreale.ca + Exemple: web.t003.czp.alliance-boreale.ca → 10.0.10.20 + ``` + +6. **Créer la VM dans Proxmox** + ```bash + qm create 30001 \ + --name czp-t003-web-prod-01 \ + --net0 virtio,bridge=vmbr0,tag=10 \ + --ipconfig0 ip=10.0.10.20/23,gw=10.0.0.1 + ``` + +### 9.3 Migration d'une VM Existante + +**Pour renommer selon le nouveau standard :** + +1. **Identifier les attributs actuels** + ``` + VMID actuel: 104 + Nom actuel: vm-web-01 + IP actuelle: 10.50.100.5 + ``` + +2. **Déterminer les nouveaux attributs** + ``` + Catégorie: Tenant 001 + Type: Web + → VMID: 10001 + → IP: 10.0.10.1 + → Nom: czp-t001-web-prod-01 + → DNS: web.t001.czp.alliance-boreale.ca + ``` + +3. **Planifier la migration** + ``` + - Fenêtre de maintenance + - Backup complet + - Plan de rollback + ``` + +4. **Exécuter la migration** + ```bash + # Arrêter la VM + qm stop 104 + + # Renommer (si VMID change, recréer) + qm set 104 --name czp-t001-web-prod-01 + + # Changer l'IP (dans la VM) + # Mettre à jour DNS + # Redémarrer + qm start 104 + + # Valider + ``` + +--- + +## 10. Exemples Complets + +### 10.1 Infrastructure Minimale (Bronze) + +**Membre : Chezlepro (czp)** + +| VMID | Nom | IP | DNS | Description | +|------|-----|-----|-----|-------------| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | DNS Maître | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | Orchestration | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | Backups | + +### 10.2 Infrastructure Complète (Or) + +**Membre : Chezlepro (czp)** + +| VMID | Nom | IP | DNS | +|------|-----|-----|-----| +| 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | +| 02002 | czp-infra-dns-slave1-prod-01 | 10.0.2.11 | dns-slave1.infra.czp.ab.ca | +| 02003 | czp-infra-dns-slave2-prod-01 | 10.0.2.12 | dns-slave2.infra.czp.ab.ca | +| 02101 | czp-infra-vpn-gw-nul-prod-01 | 10.0.2.20 | vpn-nul.infra.czp.ab.ca | +| 02102 | czp-infra-vpn-gw-tli-prod-01 | 10.0.2.21 | vpn-tli.infra.czp.ab.ca | +| 02301 | czp-infra-proxy-haproxy-prod-01 | 10.0.2.30 | proxy.infra.czp.ab.ca | +| 03001 | czp-infra-ceph-mon1-prod-01 | 10.0.1.50 | ceph-mon1.infra.czp.ab.ca | +| 03002 | czp-infra-ceph-mon2-prod-01 | 10.0.1.51 | ceph-mon2.infra.czp.ab.ca | +| 03003 | czp-infra-ceph-mon3-prod-01 | 10.0.1.52 | ceph-mon3.infra.czp.ab.ca | +| 03301 | czp-infra-pbs-backup-prod-01 | 10.0.1.30 | backup.infra.czp.ab.ca | +| 04001 | czp-infra-ansible-ctrl-prod-01 | 10.0.1.10 | ansible.infra.czp.ab.ca | +| 04101 | czp-infra-ci-runner1-prod-01 | 10.0.1.60 | ci-runner1.infra.czp.ab.ca | +| 04102 | czp-infra-ci-runner2-prod-01 | 10.0.1.61 | ci-runner2.infra.czp.ab.ca | +| 04201 | czp-infra-git-forgejo-prod-01 | 10.0.1.20 | git.infra.czp.ab.ca | +| 04301 | czp-infra-db-platform-prod-01 | 10.0.1.31 | db.infra.czp.ab.ca | +| 04401 | czp-infra-api-admin-prod-01 | 10.0.1.40 | api.infra.czp.ab.ca | +| 04501 | czp-infra-dashboard-react-prod-01 | 10.0.1.41 | dashboard.infra.czp.ab.ca | + +### 10.3 Tenant Multi-Services + +**Tenant 001 - Client "Acme Corp"** + +| VMID | Nom | IP | DNS | Description | +|------|-----|-----|-----|-------------| +| 10001 | czp-t001-web-prod-01 | 10.0.10.1 | web.t001.czp.ab.ca | Frontend Nginx | +| 10002 | czp-t001-web-prod-02 | 10.0.10.2 | web.t001.czp.ab.ca | Frontend HA | +| 10011 | czp-t001-api-fastapi-prod-01 | 10.0.10.3 | api.t001.czp.ab.ca | Backend API | +| 10021 | czp-t001-db-postgres-prod-01 | 10.0.10.4 | db.t001.czp.ab.ca | PostgreSQL 15 | +| 10031 | czp-t001-cache-redis-prod-01 | 10.0.10.5 | cache.t001.czp.ab.ca | Redis Cache | +| 10041 | czp-t001-worker-celery-prod-01 | 10.0.10.6 | worker.t001.czp.ab.ca | Celery Worker | +| 10061 | czp-t001-web-staging-01 | 10.0.10.7 | web-stg.t001.czp.ab.ca | Staging Web | + +### 10.4 Architecture Fédérée (3 Membres) + +**Services DNS exposés entre membres :** + +| Membre | VMID | Nom | IP Interne | DNS Fédéré | IP Fédérée (172.16.x.x) | +|--------|------|-----|------------|------------|-------------------------| +| Chezlepro | 02001 | czp-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.czp.ab.ca | 172.16.1.10 | +| Nuage Libre | 02001 | nul-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.nul.ab.ca | 172.16.2.10 | +| TechnoLibre | 02001 | tli-infra-dns-master-prod-01 | 10.0.2.10 | dns-master.infra.tli.ab.ca | 172.16.3.10 | + +**Note :** Les VMIDs sont identiques (02001) car chaque membre a son propre Proxmox. Les IPs internes sont identiques (10.0.2.10) car isolées par NAT. Les IPs fédérées (172.16.x.x) sont uniques et routées via tunnels VPN. + +--- + +## 11. Migration et Adoption + +### 11.1 Stratégie de Migration + +**Phase 1 : Documentation (Semaine 1-2)** +- [ ] Valider ce standard avec le Cercle Technique +- [ ] Obtenir le consentement de tous les membres actuels +- [ ] Publier dans la documentation officielle +- [ ] Former les administrateurs de chaque membre + +**Phase 2 : Nouveaux Déploiements (Semaine 3+)** +- [ ] Toute nouvelle VM doit suivre ce standard +- [ ] Utiliser les templates Ansible/Terraform mis à jour +- [ ] Documenter dans le registre + +**Phase 3 : Migration Progressive (Mois 2-6)** +- [ ] Inventorier toutes les VMs existantes +- [ ] Prioriser par criticité (services critiques en dernier) +- [ ] Planifier fenêtres de maintenance +- [ ] Migrer par lots (5-10 VMs à la fois) +- [ ] Valider après chaque lot + +**Phase 4 : Consolidation (Mois 7-12)** +- [ ] Vérifier conformité à 100% +- [ ] Mettre à jour toute la documentation +- [ ] Former les nouveaux membres sur ce standard + +### 11.2 Outils de Migration + +**Script d'Audit :** +```bash +#!/bin/bash +# audit-nomenclature.sh +# Vérifie la conformité des VMs au standard v2.0 + +for vmid in $(qm list | awk '{print $1}' | grep -v VMID); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,]*\).*/\1/') + + echo "VMID: $vmid | Nom: $name | IP: $ip" + + # Vérifier conformité VMID + if [[ ! $vmid =~ ^(0[1-4][0-9]{3}|[1-9][0-9]{4})$ ]]; then + echo " ⚠️ VMID non conforme" + fi + + # Vérifier conformité nom + if [[ ! $name =~ ^[a-z]+-((infra)|(t[0-9]{3}))-[a-z0-9-]+-prod-[0-9]{2}$ ]]; then + echo " ⚠️ Nom non conforme" + fi + + echo "" +done +``` + +**Script de Génération DNS :** +```bash +#!/bin/bash +# generate-dns-records.sh +# Génère les enregistrements DNS à partir de l'inventaire Proxmox + +MEMBER="czp" +DOMAIN="alliance-boreale.ca" + +echo "; Infrastructure DNS Records" +for vmid in $(qm list | grep "infra" | awk '{print $1}'); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,\/]*\).*/\1/') + service=$(echo $name | cut -d'-' -f3-) + + echo "${service}.infra.${MEMBER}.${DOMAIN}. IN A ${ip}" +done + +echo "" +echo "; Tenant DNS Records" +for vmid in $(qm list | grep "\-t[0-9]" | awk '{print $1}'); do + name=$(qm config $vmid | grep "name:" | awk '{print $2}') + ip=$(qm config $vmid | grep "ipconfig0" | sed 's/.*ip=\([^,\/]*\).*/\1/') + tenant=$(echo $name | grep -oP 't\d{3}') + service=$(echo $name | cut -d'-' -f3) + + echo "${service}.${tenant}.${MEMBER}.${DOMAIN}. IN A ${ip}" +done +``` + +### 11.3 Checklist de Conformité + +**Pour chaque VM :** +- [ ] VMID respecte le format (0CTTII ou TTTII) +- [ ] Nom VM respecte le format +- [ ] IP cohérente avec la fonction +- [ ] Enregistrement DNS créé et fonctionnel +- [ ] Documenté dans l'inventaire +- [ ] Tags Proxmox appropriés +- [ ] Monitoring configuré + +--- + +## 12. Annexes + +### 12.1 Glossaire + +| Terme | Définition | +|-------|------------| +| **VMID** | Identifiant numérique unique d'une VM dans Proxmox | +| **Fédéré** | Membre de L'Alliance Boréale | +| **Tenant** | Client/organisation hébergé par un membre | +| **Infrastructure Fédéré** | Services propres au membre (couches 1-4) | +| **NAT** | Network Address Translation - isole l'espace 10.0.0.0/8 | +| **Espace Fédératif** | Plage 172.16.0.0/12 routée entre membres via tunnels | + +### 12.2 Références + +- **Document 03** : Standards Techniques (Plan d'Adressage IP v3) +- **Document 01** : Charte Fondatrice (Architecture 8 Couches) +- **Document 07** : Guide d'Intégration Technique +- **Document 14** : Structure YAML du Registraire + +### 12.3 Table de Conversion VMID Legacy → v2.0 + +**Si vous avez des VMs avec anciens VMIDs :** + +| Fonction | VMID Legacy | VMID v2.0 | Justification | +|----------|-------------|-----------|---------------| +| DNS Master | 100 | 02001 | Couche 2, DNS (00), Instance 1 | +| DNS Slave | 101 | 02002 | Couche 2, DNS (00), Instance 2 | +| Ansible | 200 | 04001 | Couche 4, Ansible (00), Instance 1 | +| PostgreSQL | 150 | 04301 | Couche 4, DB Platform (30), Instance 1 | +| Web Tenant 1 | 1001 | 10001 | Tenant 001, Instance 01 | +| DB Tenant 1 | 1002 | 10021 | Tenant 001, Instance 21 (DB) | + +### 12.4 FAQ + +**Q : Que faire si j'ai plus de 99 VMs pour un tenant ?** +R : Augmenter le nombre de chiffres pour l'instance (TTTIII au lieu de TTTII), ou subdiviser en sous-tenants (t001a, t001b). + +**Q : Puis-je utiliser des VMIDs personnalisés ?** +R : Non pour les nouveaux déploiements. Le standard doit être respecté pour la cohérence fédérale. + +**Q : Les VMIDs entre membres peuvent-ils être identiques ?** +R : Oui ! Chaque membre a son propre Proxmox. czp-002 peut avoir VMID 02001, et nul-002 aussi. + +**Q : Comment gérer les environnements dev/staging ?** +R : Utiliser le champ `` dans le nom (prod, stg, dev). L'IP peut être dans un sous-réseau dédié (ex: 10.0.100.0/24 pour staging). + +**Q : Faut-il migrer toutes les VMs immédiatement ?** +R : Non. Migration progressive recommandée sur 6-12 mois. Nouveaux déploiements doivent être conformes immédiatement. + +**Q : Comment documenter les exceptions ?** +R : Dans le registre des VMs avec justification. Exceptions doivent être validées par le Cercle Technique. + +### 12.5 Templates de Documentation + +**Template Fiche VM (YAML) :** +```yaml +vm: + vmid: 02001 + name: czp-infra-dns-master-prod-01 + member: czp-001 + category: infrastructure + layer: 2 + service_type: dns + + network: + ip: 10.0.2.10 + subnet: /24 + gateway: 10.0.0.1 + vlan: 2 + + dns: + internal: dns-master.infra.czp.alliance-boreale.ca + federated: dns-master.infra.czp.alliance-boreale.ca + + resources: + cpu: 2 + ram: 4096 + disk: 100G + + backup: + enabled: true + schedule: daily + retention: 30d + + monitoring: + enabled: true + checks: + - dns_query + - process_powerdns + - disk_usage + + tags: + - infrastructure + - dns + - critical + - layer-2 +``` + +**Template Entrée Inventaire Ansible :** +```yaml +# inventory/hosts.yml +all: + children: + infrastructure: + children: + layer_2_network: + hosts: + dns-master.infra.czp.alliance-boreale.ca: + ansible_host: 10.0.2.10 + vmid: 02001 + layer: 2 + service: dns-master + + layer_4_orchestration: + hosts: + ansible.infra.czp.alliance-boreale.ca: + ansible_host: 10.0.1.10 + vmid: 04001 + layer: 4 + service: ansible-controller + + tenants: + children: + tenant_001: + hosts: + web.t001.czp.alliance-boreale.ca: + ansible_host: 10.0.10.1 + vmid: 10001 + tenant: 001 + service: web +``` + +--- + +## 13. Validation et Approbation + +### 13.1 Processus de Validation + +**Ce document doit être validé par :** +- [ ] **Cercle Technique** - Validation technique de la nomenclature +- [ ] **Expert DevOps/SRE** - Validation Proxmox et automatisation +- [ ] **Expert Réseau** - Validation plan IP et DNS +- [ ] **Tous les membres actuels** - Consentement pour adoption + +**Timeline :** +- Semaine 1-2 : Revue et commentaires +- Semaine 3 : Intégration des retours +- Semaine 4 : Vote de consentement +- Semaine 5+ : Publication et déploiement + +### 13.2 Critères d'Acceptation + +Pour que ce standard soit adopté : +- ✅ Aucun membre n'a d'objection majeure (principe de consentement) +- ✅ Compatibilité confirmée avec infrastructures existantes +- ✅ Outils de migration validés et testés +- ✅ Documentation complète et claire +- ✅ Formation prévue pour tous les administrateurs + +### 13.3 Versionnage + +**Version actuelle : 2.0 (DRAFT)** + +Historique des versions : +- v2.0 (2025-10-21) : Création initiale - Nomenclature unifiée complète +- v2.1 (future) : Ajustements après retours terrain + +--- + +## 14. Maintenance du Standard + +### 14.1 Révisions + +Ce document sera révisé : +- **Annuellement** (octobre de chaque année) +- **À la demande** si problème majeur détecté +- **Lors d'évolutions** de l'architecture (nouveau plan IP, etc.) + +### 14.2 Propositions de Modification + +Pour proposer une modification : +1. Ouvrir une issue dans le dépôt Git de gouvernance +2. Documenter le problème et la solution proposée +3. Discussion au Cercle Technique (1 réunion minimum) +4. Vote de consentement si impact majeur +5. Publication de la nouvelle version + +### 14.3 Responsable du Document + +**Responsable principal :** Cercle Technique +**Contact :** technique@alliance-boreale.ca +**Dépôt Git :** https://forge.alliance-boreale.ca/standards/nomenclature + +--- + +## 15. Conclusion + +### 15.1 Récapitulatif + +Ce Standard de Nomenclature v2.0 établit : +- ✅ Un système unifié VMID ↔ IP ↔ Nom ↔ DNS +- ✅ Une organisation claire Infrastructure vs Tenants +- ✅ Une scalabilité jusqu'à 999 tenants par membre +- ✅ Une cohérence avec le Plan d'Adressage IP v3 +- ✅ Des procédures opérationnelles claires +- ✅ Une stratégie de migration progressive + +### 15.2 Bénéfices Attendus + +**Pour les Membres :** +- Gestion simplifiée de l'infrastructure +- Onboarding rapide des nouveaux administrateurs +- Automatisation facilitée (Ansible, Terraform) +- Audit et conformité simplifiés + +**Pour L'Alliance :** +- Interopérabilité renforcée +- Documentation homogène +- Support technique facilité +- Crédibilité professionnelle + +### 15.3 Prochaines Étapes + +1. **Validation** : Soumettre au Cercle Technique (semaine du 28 octobre 2025) +2. **Révision** : Intégrer retours (semaine du 4 novembre 2025) +3. **Vote** : Consentement des membres (semaine du 11 novembre 2025) +4. **Publication** : Version finale (15 novembre 2025) +5. **Formation** : Sessions pour administrateurs (décembre 2025) +6. **Déploiement** : Nouveaux projets conformes (janvier 2026) +7. **Migration** : VMs existantes (jan-déc 2026) + +--- + +**« Une nomenclature claire est le fondement d'une infrastructure maîtrisée. »** + +--- + +**FIN DU DOCUMENT** + +**Standard de Nomenclature v2.0 - L'Alliance Boréale** +**© 2025 L'Alliance Boréale - CC-BY-SA 4.0** +**Document préparé avec l'assistance de Claude (Anthropic)** \ No newline at end of file diff --git a/docs/architecture/readme_package.md b/docs/architecture/readme_package.md new file mode 100644 index 0000000..7458d63 --- /dev/null +++ b/docs/architecture/readme_package.md @@ -0,0 +1,244 @@ +# Package Complet - Nomenclature v2.0 +## L'Alliance Boréale + +**Version :** 1.0 +**Date :** 21 octobre 2025 +**Licence :** AGPL-3.0 (code) / CC-BY-SA 4.0 (documentation) + +--- + +## 📦 Contenu du Package + +Ce package complet contient **tout ce dont vous avez besoin** pour adopter le Standard de Nomenclature v2.0 dans votre infrastructure Proxmox. + +### 📚 Documentation (5 documents) + +1. **Standard de Nomenclature v2.0** (60+ pages) + - Spécification complète du standard + - Format VMID, IP, noms VMs, DNS + - Tables de correspondance exhaustives + - Procédures opérationnelles + +2. **Scripts de Migration et d'Audit** (documentation + 6 scripts) + - `audit-nomenclature.sh` - Audit de conformité + - `generate-dns-records.sh` - Génération zone DNS + - `generate-inventory.sh` - Génération inventaire Ansible + - `migrate-vm.sh` - Migration assistée + - `validate-vmid.sh` - Validation VMID + - `allocate-ip.sh` - Allocation IP tenants + +3. **Guide de Formation** (40+ pages) + - Formation complète 2-3 heures + - 8 exercices pratiques avec solutions + - Aide-mémoire imprimable + - Test de certification (10 questions) + +4. **Templates Ansible & Terraform** + - Modules Ansible (création VM, audit, compliance) + - Modules Terraform (infra + tenants) + - Exemples d'utilisation + - Makefile d'automatisation + +5. **README Package** (ce document) + - Vue d'ensemble + - Quick Start + - Troubleshooting + +--- + +## 🚀 Quick Start (15 minutes) + +### Étape 1 : Installation des Scripts + +```bash +# Télécharger le package +wget https://forge.alliance-boreale.ca/nomenclature-v2-package.tar.gz +tar xzf nomenclature-v2-package.tar.gz +cd nomenclature-v2 + +# Installer les scripts +sudo bash scripts/install-nomenclature-tools.sh + +# Configuration +# Suivre les prompts pour MEMBER_ID et DNS_DOMAIN +``` + +### Étape 2 : Premier Audit + +```bash +# Lancer un audit de conformité +audit-nomenclature.sh + +# Résultat attendu : +# ✅ VMs conformes : X +# ❌ VMs non conformes : Y +# Taux de conformité: Z% +``` + +### Étape 3 : Validation d'un VMID + +```bash +# Tester la validation +validate-vmid.sh 02001 + +# Résultat : +# ✅ VMID VALIDE +# Type: Infrastructure +# Couche: 2 (Réseau) +``` + +### Étape 4 : Première Migration (Simulation) + +```bash +# Migration en mode dry-run +DRY_RUN=true migrate-vm.sh 104 10001 \ + czp-t001-web-prod-01 10.0.10.1 + +# Vérifier la sortie avant de lancer en réel +``` + +### Étape 5 : Documentation + +```bash +# Lire le standard complet +less docs/Standard_Nomenclature_v2.0.md + +# Lire le guide de formation +less docs/Guide_Formation_v2.0.md +``` + +--- + +## 📖 Structure du Package + +``` +nomenclature-v2/ +│ +├── README.md # Ce fichier +├── LICENSE # AGPL-3.0 +│ +├── docs/ +│ ├── Standard_Nomenclature_v2.0.md # Spec complète +│ ├── Guide_Formation_v2.0.md # Formation +│ └── aide-memoire.pdf # Carte de référence +│ +├── scripts/ +│ ├── install-nomenclature-tools.sh # Installation +│ ├── audit-nomenclature.sh # Audit +│ ├── generate-dns-records.sh # DNS +│ ├── generate-inventory.sh # Inventaire +│ ├── migrate-vm.sh # Migration +│ ├── validate-vmid.sh # Validation +│ └── allocate-ip.sh # Allocation IP +│ +├── ansible/ +│ ├── inventory/ +│ │ └── proxmox.yml # Inventaire dynamique +│ ├── playbooks/ +│ │ ├── create-infra-vm.yml # Création VM infra +│ │ ├── create-tenant-vm.yml # Création VM tenant +│ │ └── audit-nomenclature.yml # Audit Ansible +│ └── roles/ +│ └── nomenclature_compliance/ # Role de conformité +│ +├── terraform/ +│ ├── modules/ +│ │ ├── infra-vm/ # Module VM infrastructure +│ │ └── tenant-vm/ # Module VM tenant +│ ├── examples/ +│ │ ├── bronze-infra/ # Infrastructure Bronze +│ │ ├── silver-infra/ # Infrastructure Argent +│ │ └── tenant-stack/ # Stack tenant complète +│ ├── main.tf # Exemple principal +│ ├── variables.tf # Variables +│ └── outputs.tf # Outputs +│ +├── templates/ +│ ├── vm-creation-request.md # Template demande création VM +│ ├── migration-plan.md # Template plan de migration +│ └── compliance-report.md # Template rapport conformité +│ +└── examples/ + ├── infrastructure-bronze.txt # Exemple infra Bronze + ├── infrastructure-gold.txt # Exemple infra Or + └── tenant-multiservice.txt # Exemple tenant complet +``` + +--- + +## 💡 Cas d'Usage + +### 1. Audit de Conformité de l'Existant + +```bash +# Lancer audit +audit-nomenclature.sh > audit-$(date +%Y%m%d).log + +# Analyser le rapport CSV +grep "NON CONFORME" /tmp/audit-nomenclature-*.csv + +# Créer plan de migration +cat audit-*.log | grep "NON CONFORME" > migration-todo.txt +``` + +### 2. Création Nouvelle VM Infrastructure + +**Option A : Script interactif** +```bash +ansible-playbook ansible/playbooks/create-infra-vm.yml +# Suivre les prompts +``` + +**Option B : Terraform** +```bash +cd terraform/examples/bronze-infra +terraform init +terraform plan +terraform apply +``` + +**Option C : Manuel** +```bash +# 1. Déterminer VMID +validate-vmid.sh 02003 # DNS Slave 3 + +# 2. Créer VM +qm create 02003 \ + --name czp-infra-dns-slave3-prod-01 \ + --clone debian-12-template \ + --net0 virtio,bridge=vmbr0,tag=2 \ + --ipconfig0 ip=10.0.2.12/24,gw=10.0.0.1 + +# 3. Ajouter DNS +echo "dns-slave3.infra.czp.alliance-boreale.ca. IN A 10.0.2.12" \ + >> /var/lib/alliance-boreale/dns-records.zone +``` + +### 3. Migration Progressive + +```bash +# Étape 1 : Audit initial +audit-nomenclature.sh + +# Étape 2 : Créer plan (fichier CSV) +# migration-plan.csv : +# VMID_SRC,VMID_DST,NAME,IP +# 104,10001,czp-t001-web-prod-01,10.0.10.1 +# 105,10011,czp-t001-api-prod-01,10.0.10.3 + +# Étape 3 : Migrer par lots +while IFS=, read -r src dst name ip; do + echo "Migration $src -> $dst" + DRY_RUN=true migrate-vm.sh "$src" "$dst" "$name" "$ip" + read -p "Continuer? (y/n) " -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]]; then + migrate-vm.sh "$src" "$dst" "$name" "$ip" + fi +done < migration-plan.csv +``` + +### 4. Déploiement Nouveau Tenant + +```bash +# Via Ansible +ansible-playbook ansible/playbooks/ \ No newline at end of file diff --git a/docs/architecture/resolution_adoption.md b/docs/architecture/resolution_adoption.md new file mode 100644 index 0000000..0a26845 --- /dev/null +++ b/docs/architecture/resolution_adoption.md @@ -0,0 +1,431 @@ +# RÉSOLUTION D'ADOPTION +## Standard de Nomenclature v2.0 +### L'Alliance Boréale + +--- + +**Numéro de résolution :** 2025-TECH-001 +**Date de proposition :** 21 octobre 2025 +**Cercle émetteur :** Cercle Technique +**Processus :** Consentement Sociocratique +**Statut :** PROPOSITION (en attente de validation) + +--- + +## CONTEXTE + +### Situation Actuelle + +L'Alliance Boréale compte actuellement **3 membres actifs** (Chezlepro, Nuage Libre, TechnoLibre) avec une infrastructure totale d'environ **120 machines virtuelles** réparties entre infrastructure propre et tenants hébergés. + +**Problématiques identifiées :** + +1. **Absence de standard unifié** pour l'identification des ressources +2. **Nomenclature incohérente** entre les membres (VMIDs, noms, IPs) +3. **Difficultés d'automatisation** (Ansible, Terraform) dues au manque de structure +4. **Complexité d'audit** pour la labellisation (Bronze, Argent, Or, Platine) +5. **Onboarding lent** des nouveaux administrateurs +6. **Risques opérationnels** (erreurs de manipulation, confusion) + +### Besoins Exprimés + +Lors des réunions du Cercle Technique (août-octobre 2025), les membres ont exprimé le besoin de : + +- ✅ **Standardiser** l'identification de toutes les ressources (VMs, IPs, DNS) +- ✅ **Faciliter l'automatisation** avec des patterns prévisibles +- ✅ **Simplifier les audits** de conformité pour la labellisation +- ✅ **Accélérer l'onboarding** avec une documentation claire +- ✅ **Améliorer la scalabilité** (prévoir 999 tenants par membre) + +--- + +## PROPOSITION + +### Objet de la Résolution + +**IL EST PROPOSÉ** d'adopter le **Standard de Nomenclature v2.0** comme standard officiel de L'Alliance Boréale pour l'identification et l'organisation des ressources d'infrastructure. + +### Composants du Standard + +Le Standard de Nomenclature v2.0 comprend : + +#### 1. Spécification Technique (60+ pages) +- Format VMID mnémotechnique (0CTTII pour infra, TTTII pour tenants) +- Plan d'adressage IP unifié (10.0.0.0/8 par membre, derrière NAT) +- Nomenclature VMs (-infra/t---) +- Nomenclature DNS (.infra/t..alliance-boreale.ca) +- Tables de correspondance complètes + +#### 2. Outillage (6 scripts) +- `audit-nomenclature.sh` - Audit de conformité +- `generate-dns-records.sh` - Génération zone DNS +- `generate-inventory.sh` - Génération inventaire Ansible +- `migrate-vm.sh` - Migration assistée avec simulation +- `validate-vmid.sh` - Validation format VMID +- `allocate-ip.sh` - Allocation IP tenants (IPAM) + +#### 3. Formation et Documentation +- Guide de formation (40+ pages, 8 exercices pratiques) +- Test de certification (10 questions + exercice final) +- Templates Ansible et Terraform +- Aide-mémoire imprimable + +#### 4. Gouvernance +- Processus de révision annuelle +- Procédures de modification (RFC) +- Versionnage sémantique (v2.x.x) + +--- + +## MODALITÉS D'ADOPTION + +### 1. Adoption du Standard + +**IL EST RÉSOLU :** + +**QUE** le Standard de Nomenclature v2.0, tel que documenté dans le package complet daté du 21 octobre 2025, soit adopté comme **standard officiel obligatoire** pour tous les membres de L'Alliance Boréale. + +### 2. Date d'Entrée en Vigueur + +**QUE** ce standard entre en vigueur selon le calendrier suivant : + +- **Immédiat (21 octobre 2025)** : Publication officielle du standard +- **1er décembre 2025** : Formation obligatoire de tous les administrateurs +- **1er janvier 2026** : Obligation pour tous **nouveaux déploiements** +- **31 décembre 2026** : Objectif de conformité à 100% pour l'existant + +### 3. Obligations des Membres + +**QUE** chaque membre s'engage à : + +#### A) Formation (avant 1er décembre 2025) +- [ ] Former tous les administrateurs système (min. 1 par membre) +- [ ] Certifier au moins 1 administrateur par membre (niveau 2) +- [ ] Désigner 1 "référent nomenclature" par membre + +#### B) Nouveaux Déploiements (à partir du 1er janvier 2026) +- [ ] Respecter le standard v2.0 pour **toute nouvelle VM** +- [ ] Utiliser les scripts fournis pour validation (validate-vmid.sh) +- [ ] Documenter toute exception (avec justification validée) + +#### C) Migration de l'Existant (avant 31 décembre 2026) +- [ ] Réaliser un audit initial (avant 31 janvier 2026) +- [ ] Établir un plan de migration (avant 28 février 2026) +- [ ] Migrer par lots (5-10 VMs/mois minimum) +- [ ] Atteindre 80% de conformité avant 30 juin 2026 +- [ ] Atteindre 100% de conformité avant 31 décembre 2026 + +#### D) Reporting +- [ ] Rapport mensuel de conformité au Cercle Technique +- [ ] Partage des retours d'expérience (bonnes pratiques, difficultés) + +### 4. Ressources Allouées + +**QUE** L'Alliance Boréale alloue les ressources suivantes : + +#### Coordination (Banque de Temps) +- **30 heures** : Animation sessions de formation (réparties entre experts) +- **20 heures** : Support technique aux membres (canal dédié Matrix) +- **10 heures** : Maintenance documentation et scripts + +#### Infrastructure Commune +- **Forge Git** : Hébergement du code et documentation +- **Wiki** : Documentation interactive et exemples +- **Forum** : Entraide entre membres + +#### Budget Financier (si nécessaire) +- **0 $** : Tout en logiciel libre et Banque de Temps +- **Réserve** : 500 $ pour formation externe si expertise manquante + +### 5. Exceptions et Dérogations + +**QUE** des exceptions puissent être accordées selon ce processus : + +#### Cas Justifiant une Exception +- Contraintes techniques insurmontables (matériel legacy) +- Dépendances externes non migrables à court terme +- Coût de migration disproportionné pour VM en fin de vie + +#### Processus d'Exception +1. **Demande écrite** au Cercle Technique (formulaire dédié) +2. **Justification technique** détaillée + impact + alternatives explorées +3. **Validation** par 2 experts du Cercle Technique +4. **Durée limitée** : Max 12 mois, renouvellement possible 1 fois +5. **Plan de mise en conformité** obligatoire dans la demande + +#### Registre des Exceptions +- Tenu à jour dans `governance/nomenclature-exceptions.yml` +- Consultation publique par tous les membres +- Révision trimestrielle par le Cercle Technique + +### 6. Maintenance et Évolution + +**QUE** le standard soit maintenu selon ces principes : + +#### Responsabilité +- **Propriétaire** : Cercle Technique de L'Alliance Boréale +- **Gardien du standard** : 1 membre désigné (rotation annuelle) +- **Contributeurs** : Tous les membres (via RFC) + +#### Révisions +- **Mineures (v2.x)** : Corrections, clarifications → Validation Cercle Technique +- **Majeures (v3.0)** : Changements structurels → Consentement tous membres +- **Fréquence** : Révision annuelle obligatoire (octobre) + +#### Processus RFC (Request for Comments) +1. Proposition ouverte sur la forge (`rfc/NNNN-titre.md`) +2. Discussion publique (min. 2 semaines) +3. Présentation au Cercle Technique +4. Décision par consentement (si impact majeur) +5. Intégration dans version suivante + +--- + +## IMPACTS ET BÉNÉFICES ATTENDUS + +### Impacts Positifs + +#### Court Terme (6 mois) +- ✅ **Clarté opérationnelle** : Toute ressource identifiable immédiatement +- ✅ **Réduction erreurs** : -80% d'erreurs de manipulation (estimation) +- ✅ **Automatisation** : Playbooks Ansible génériques réutilisables +- ✅ **Onboarding** : Temps de formation -50% pour nouveaux admins + +#### Moyen Terme (1 an) +- ✅ **Conformité audits** : Simplification audits de labellisation +- ✅ **Scalabilité** : Capacité d'accueillir 999 tenants par membre +- ✅ **Professionnalisme** : Crédibilité renforcée de L'Alliance +- ✅ **Collaboration** : Entraide facilitée entre membres + +#### Long Terme (2 ans) +- ✅ **Maturité** : Infrastructure de niveau "entreprise" +- ✅ **Résilience** : Documentation permettant continuité en cas de départ +- ✅ **Innovation** : Base solide pour outils avancés (IPAM auto, API) +- ✅ **Rayonnement** : Standard pouvant influencer la communauté Proxmox + +### Impacts Négatifs (Mitigations) + +#### Charge de Travail Initiale +- ⚠️ **Impact** : ~40h par membre pour migration complète +- ✅ **Mitigation** : Migration progressive sur 12 mois, scripts d'assistance + +#### Courbe d'Apprentissage +- ⚠️ **Impact** : 3h de formation par administrateur +- ✅ **Mitigation** : Documentation claire, exercices pratiques, certification + +#### Résistance au Changement +- ⚠️ **Impact** : Confort avec l'existant, peur de la complexité +- ✅ **Mitigation** : Démonstrations, retours d'expérience, support dédié + +--- + +## MÉTRIQUES DE SUCCÈS + +### Indicateurs Quantitatifs (KPIs) + +| Métrique | Valeur Actuelle | Cible 6 mois | Cible 12 mois | +|----------|-----------------|--------------|---------------| +| **Taux de conformité VMs** | 0% | 50% | 100% | +| **Admins formés** | 0/9 | 6/9 (67%) | 9/9 (100%) | +| **Admins certifiés** | 0/9 | 3/9 (33%) | 6/9 (67%) | +| **Temps onboarding nouvel admin** | 2 jours | 1 jour | 0.5 jour | +| **Erreurs de manipulation/mois** | ~10 | <5 | <2 | +| **Temps audit conformité** | 4h | 1h | 0.5h (automatisé) | + +### Indicateurs Qualitatifs + +- **Satisfaction administrateurs** : Sondage trimestriel (cible >4/5) +- **Qualité documentation** : Feedback utilisateurs (cible >4/5) +- **Facilité d'automatisation** : Nombre de playbooks réutilisables +- **Rayonnement externe** : Mentions dans communauté Proxmox + +--- + +## RISQUES ET PLAN DE CONTINGENCE + +### Risques Identifiés + +#### Risque 1 : Faible Adoption +- **Probabilité** : Faible +- **Impact** : Élevé +- **Mitigation** : Obligation pour nouveaux déploiements, formation obligatoire +- **Contingence** : Accompagnement renforcé, exemples concrets + +#### Risque 2 : Standard Trop Complexe +- **Probabilité** : Moyenne +- **Impact** : Moyen +- **Mitigation** : Formation de qualité, scripts d'assistance +- **Contingence** : Simplification v2.1 si feedback négatif massif + +#### Risque 3 : Coût Migration Sous-Estimé +- **Probabilité** : Moyenne +- **Impact** : Moyen +- **Mitigation** : Timeline souple (12 mois), migration progressive +- **Contingence** : Extension deadline si justifié (vote) + +#### Risque 4 : Obsolescence Rapide +- **Probabilité** : Faible +- **Impact** : Élevé +- **Mitigation** : Processus RFC, révision annuelle +- **Contingence** : Refonte v3.0 si changement technologique majeur + +--- + +## PROCESSUS DE VALIDATION + +### Étapes de Validation + +#### 1. Révision Technique (Semaine 1-2) +- [ ] Lecture du package complet par tous les membres du Cercle Technique +- [ ] Identification des points d'amélioration +- [ ] Soumission des commentaires (forge Git ou Matrix) + +#### 2. Intégration Retours (Semaine 3) +- [ ] Consolidation des retours par le responsable du standard +- [ ] Modifications du standard (version 2.0.1 si nécessaire) +- [ ] Publication version révisée + +#### 3. Réunion de Validation (Semaine 4) +- [ ] Réunion du Cercle Technique (2-3 heures) +- [ ] Présentation du standard (30 min) +- [ ] Questions/Réponses (30 min) +- [ ] Tour de consentement (30 min) +- [ ] Formalisation de la résolution + +#### 4. Vote de Consentement +- [ ] Chaque membre exprime son consentement ou objection +- [ ] Si objection : Discussion et recherche de solutions +- [ ] Si aucune objection bloquante : **Résolution adoptée** + +### Critères de Consentement + +Un membre donne son **consentement** s'il peut affirmer : + +> "Je n'ai pas d'objection raisonnable et argumentée qui rendrait l'adoption de ce standard **nuisible** pour L'Alliance ou pour mon organisation." + +**Note** : Le consentement n'est PAS l'unanimité. Un membre peut avoir des réserves mineures tout en donnant son consentement. + +--- + +## SIGNATURES ET ADOPTION + +### Proposition Initiale + +**Proposé par :** +- **Daniel Mathieu** - Président, Chezlepro (czp-001) +- **Cercle Technique** - L'Alliance Boréale + +**Date de proposition :** 21 octobre 2025 + +--- + +### Consentement des Membres + +#### Chezlepro (czp-001) +- [ ] **Consentement** donné le : ________________ +- [ ] **Objection** (détails ci-dessous) : + +**Signature :** ________________________ +**Nom :** Daniel Mathieu +**Fonction :** Président / Administrateur Système + +--- + +#### Nuage Libre (nul-002) +- [ ] **Consentement** donné le : ________________ +- [ ] **Objection** (détails ci-dessous) : + +**Signature :** ________________________ +**Nom :** ______________________________ +**Fonction :** ______________________________ + +--- + +#### TechnoLibre (tli-003) +- [ ] **Consentement** donné le : ________________ +- [ ] **Objection** (détails ci-dessous) : + +**Signature :** ________________________ +**Nom :** ______________________________ +**Fonction :** ______________________________ + +--- + +### Validation Finale + +**Résolution adoptée par consentement le :** _______________ + +**Validé par le Cercle Technique :** + +**Signature du Facilitateur :** +________________________ +**Nom :** ______________________________ +**Date :** ______________________________ + +--- + +## ANNEXES + +### Annexe A : Documents de Référence + +1. **Standard de Nomenclature v2.0** (60+ pages) + - Fichier : `Standard_Nomenclature_v2.0.md` + - Hash SHA256 : `[à calculer après finalisation]` + +2. **Scripts de Migration** (6 scripts) + - Répertoire : `scripts/` + - Version : 1.0 + +3. **Guide de Formation** (40+ pages) + - Fichier : `Guide_Formation_v2.0.md` + +4. **Templates Ansible/Terraform** + - Répertoires : `ansible/` et `terraform/` + +### Annexe B : Calendrier Détaillé + +| Date | Étape | Responsable | Statut | +|------|-------|-------------|--------| +| 21 oct 2025 | Proposition résolution | Daniel Mathieu | ✅ Fait | +| 28 oct 2025 | Révision technique | Cercle Technique | ⏳ En cours | +| 4 nov 2025 | Intégration retours | Daniel Mathieu | 🔜 À venir | +| 11 nov 2025 | Réunion validation | Tous membres | 🔜 À venir | +| 18 nov 2025 | Adoption officielle | Cercle Technique | 🔜 À venir | +| 1 déc 2025 | Début formations | Référents nomenclature | 🔜 À venir | +| 1 jan 2026 | Entrée en vigueur | Tous membres | 🔜 À venir | + +### Annexe C : Contacts et Responsabilités + +**Gardien du Standard (2025-2026) :** +- Nom : Daniel Mathieu +- Email : daniel@chezlepro.ca +- Matrix : @daniel:chezlepro.ca + +**Support Technique :** +- Email : technique@alliance-boreale.ca +- Matrix : #nomenclature:alliance-boreale.ca + +**Forge Git :** +- URL : https://forge.alliance-boreale.ca/standards/nomenclature +- Issues : https://forge.alliance-boreale.ca/standards/nomenclature/issues + +--- + +## HISTORIQUE DES RÉVISIONS + +| Version | Date | Auteur | Modifications | +|---------|------|--------|---------------| +| 1.0 | 21 oct 2025 | Daniel Mathieu | Proposition initiale | +| 1.1 | [future] | [nom] | [modifications après retours] | + +--- + +**FIN DE LA RÉSOLUTION** + +**Résolution n° 2025-TECH-001** +**Standard de Nomenclature v2.0** +**L'Alliance Boréale** + +--- + +**« Un standard adopté par consentement est un standard respecté. »** \ No newline at end of file diff --git a/docs/architecture/scripts_migration.sh b/docs/architecture/scripts_migration.sh new file mode 100644 index 0000000..7f41f07 --- /dev/null +++ b/docs/architecture/scripts_migration.sh @@ -0,0 +1,1248 @@ +#!/bin/bash +################################################################################ +# Scripts de Migration et d'Audit - Nomenclature v2.0 +# L'Alliance Boréale +# +# Version: 1.0 +# Date: 21 octobre 2025 +# Licence: AGPL-3.0 +# +# DESCRIPAM_FILE="/etc/alliance-boreale/ipam.txt" +DNS_OUTPUT="/var/lib/alliance-boreale/dns-records.zone" +INVENTORY_OUTPUT="/var/lib/alliance-boreale/inventory.yml" +CONFIG + +# Créer répertoires de travail +mkdir -p /var/lib/alliance-boreale +mkdir -p /var/log/alliance-boreale + +# Source configuration dans les scripts +echo "source /etc/alliance-boreale/nomenclature.conf" >> ~/.bashrc + +echo "✅ Configuration créée: /etc/alliance-boreale/nomenclature.conf" +echo "✅ Répertoires créés: /var/lib/alliance-boreale" +echo "" +echo "Scripts installés:" +echo " - audit-nomenclature.sh" +echo " - generate-dns-records.sh" +echo " - generate-inventory.sh" +echo " - migrate-vm.sh" +echo " - validate-vmid.sh" +echo " - allocate-ip.sh" +echo "" +echo "Usage:" +echo " audit-nomenclature.sh # Audit de conformité" +echo " generate-dns-records.sh # Génération DNS" +echo " generate-inventory.sh # Génération inventaire" +echo " migrate-vm.sh # Migration VM" +echo " validate-vmid.sh # Validation VMID" +echo " allocate-ip.sh # Allocation IP" +echo "" +echo "======================================================" +echo "Installation terminée!" +echo "======================================================" +INSTALL + +chmod +x /usr/local/bin/install-nomenclature-tools.sh + +################################################################################ +# DOCUMENTATION +################################################################################ + +cat > /usr/local/share/doc/nomenclature-v2-scripts.md << 'DOC' +# Documentation Scripts Nomenclature v2.0 +## L'Alliance Boréale + +## Installation + +```bash +# Exécuter le script d'installation +sudo /usr/local/bin/install-nomenclature-tools.sh + +# Ou installer manuellement +sudo cp *.sh /usr/local/bin/ +sudo chmod +x /usr/local/bin/*.sh +``` + +## Configuration + +Fichier: `/etc/alliance-boreale/nomenclature.conf` + +```bash +MEMBER_ID="czp" +DNS_DOMAIN="alliance-boreale.ca" +IPAM_FILE="/etc/alliance-boreale/ipam.txt" +``` + +## Scripts Disponibles + +### 1. audit-nomenclature.sh + +**Description:** Audit complet de conformité des VMs au standard v2.0 + +**Usage:** +```bash +audit-nomenclature.sh +``` + +**Sortie:** +- Rapport console avec couleurs +- CSV détaillé: `/tmp/audit-nomenclature-YYYYMMDD-HHMMSS.csv` +- Exit code: 0 si conforme, 1 si non-conforme + +**Exemple:** +```bash +$ audit-nomenclature.sh +====================================================== +AUDIT DE CONFORMITÉ - NOMENCLATURE v2.0 +Membre: czp +Date: 2025-10-21 14:30:00 +====================================================== + +✅ CONFORME | VMID: 02001 | Nom: czp-infra-dns-master-prod-01 | IP: 10.0.2.10 +❌ NON CONFORME | VMID: 104 | Nom: old-vm-web | IP: 10.50.100.5 + → VMID invalide; Nom invalide; IP invalide; + +====================================================== +RÉSUMÉ +====================================================== +Total VMs : 25 +Conformes : 20 +Non conformes : 5 + +Taux de conformité: 80.0% +====================================================== +``` + +### 2. generate-dns-records.sh + +**Description:** Génère les enregistrements DNS zone file à partir de Proxmox + +**Usage:** +```bash +generate-dns-records.sh > dns-records.zone +``` + +**Variables:** +```bash +MEMBER="czp" # ID membre +DNS_DOMAIN="alliance-boreale.ca" # Domaine +DNS_OUTPUT="/tmp/dns-records-${MEMBER}.zone" # Fichier sortie +``` + +**Exemple:** +```bash +$ generate-dns-records.sh +; DNS Records for czp.alliance-boreale.ca +; Generated on Mon Oct 21 14:30:00 2025 +; Standard Nomenclature v2.0 + +; ====================================================== +; INFRASTRUCTURE (Couches 1-4) +; ====================================================== +dns-master.infra.czp.alliance-boreale.ca. IN A 10.0.2.10 +dns-slave1.infra.czp.alliance-boreale.ca. IN A 10.0.2.11 +ansible.infra.czp.alliance-boreale.ca. IN A 10.0.1.10 +git.infra.czp.alliance-boreale.ca. IN A 10.0.1.20 + +; ====================================================== +; TENANTS (Couches 5-8) +; ====================================================== +web.t001.czp.alliance-boreale.ca. IN A 10.0.10.1 +db.t001.czp.alliance-boreale.ca. IN A 10.0.10.2 +``` + +### 3. generate-inventory.sh + +**Description:** Génère l'inventaire Ansible YAML à partir de Proxmox + +**Usage:** +```bash +generate-inventory.sh +``` + +**Sortie:** `/tmp/inventory-${MEMBER}.yml` + +**Exemple:** +```bash +$ generate-inventory.sh +Inventaire généré: /tmp/inventory-czp.yml + +$ cat /tmp/inventory-czp.yml +--- +# Ansible Inventory - czp +# Generated on Mon Oct 21 14:30:00 2025 + +all: + vars: + member_id: czp + domain: alliance-boreale.ca + + children: + infrastructure: + children: + layer_2: + hosts: + dns-master.infra.czp.alliance-boreale.ca: + ansible_host: 10.0.2.10 + vmid: 02001 + layer: 2 + service: dns-master + environment: prod +``` + +### 4. migrate-vm.sh + +**Description:** Migre une VM vers le nouveau standard (VMID, nom, IP) + +**Usage:** +```bash +migrate-vm.sh +``` + +**Options:** +```bash +DRY_RUN=true # Mode simulation (pas de changement réel) +``` + +**Exemple:** +```bash +# Simulation +$ DRY_RUN=true migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 + +# Migration réelle +$ migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 +====================================================== +MIGRATION VM - NOMENCLATURE v2.0 +====================================================== +VMID source : 104 +VMID dest : 10001 +Nouveau nom : czp-t001-web-prod-01 +Nouvelle IP : 10.0.10.1 +Mode simulation: false +====================================================== + +État actuel: + Nom: old-vm-web + IP : 10.50.100.5 + +Nouvel état: + Nom: czp-t001-web-prod-01 + IP : 10.0.10.1 + +Continuer? (oui/non): oui + +Étapes de migration: + +1. Création backup... + ✓ Backup créé +2. Arrêt de la VM... + ✓ VM arrêtée +3. Clonage vers nouveau VMID... + ✓ VM clonée +4. Configuration nouvelle IP... + ✓ IP configurée dans Proxmox + ⚠ ATTENTION: Modifier aussi l'IP dans la VM +5. Démarrage nouvelle VM... + ✓ VM démarrée + +====================================================== +MIGRATION TERMINÉE +====================================================== + +Prochaines étapes MANUELLES: +1. Vérifier que la VM démarre correctement +2. Connecter à la VM et changer l'IP +3. Tester la connectivité réseau +4. Créer l'entrée DNS +5. Mettre à jour l'inventaire Ansible +6. Une fois validé: qm destroy 104 +``` + +### 5. validate-vmid.sh + +**Description:** Valide qu'un VMID respecte le standard v2.0 + +**Usage:** +```bash +validate-vmid.sh +``` + +**Exemples:** +```bash +$ validate-vmid.sh 02001 +✅ VMID VALIDE +Type: Infrastructure +Couche: 2 +Type service: 00 +Instance: 01 +Description: Couche 2 - Réseau + +$ validate-vmid.sh 10001 +✅ VMID VALIDE +Type: Tenant +Tenant ID: 001 +Instance: 01 + +$ validate-vmid.sh 99999 +❌ VMID INVALIDE + +Format attendu: + Infrastructure: 0CTTII (ex: 02001) + Tenant: TTTII (ex: 10001) +``` + +### 6. allocate-ip.sh + +**Description:** Alloue la prochaine IP disponible pour un tenant + +**Usage:** +```bash +allocate-ip.sh +``` + +**Fichier IPAM:** `/etc/alliance-boreale/ipam.txt` + +**Exemple:** +```bash +$ allocate-ip.sh 001 +✅ IP DISPONIBLE: 10.0.10.1 + +Pour allouer cette IP: + echo "001 10.0.10.1 2025-10-21 10001" >> /etc/alliance-boreale/ipam.txt + +$ allocate-ip.sh 002 +Tenant 002 a déjà des IPs allouées: +002 10.0.10.10 2025-10-20 20001 +002 10.0.10.11 2025-10-20 20002 + +✅ IP DISPONIBLE: 10.0.10.12 +``` + +## Workflow de Migration Complet + +### Étape 1: Audit Initial +```bash +# Générer rapport de conformité +audit-nomenclature.sh + +# Identifier les VMs non conformes +grep "NON CONFORME" /tmp/audit-nomenclature-*.csv +``` + +### Étape 2: Planification +```bash +# Pour chaque VM non conforme, déterminer: +# - Nouveau VMID (validate-vmid.sh) +# - Nouveau nom +# - Nouvelle IP (allocate-ip.sh si tenant) + +# Exemple de plan: +cat > migration-plan.txt << EOF +# Plan de Migration - Nomenclature v2.0 + +VMID_SRC | VMID_DST | Nom Actuel | Nouveau Nom | IP Actuelle | Nouvelle IP +---------|----------|-----------------|--------------------------------|--------------|------------- +104 | 10001 | old-vm-web | czp-t001-web-prod-01 | 10.50.100.5 | 10.0.10.1 +105 | 10011 | web-api | czp-t001-api-prod-01 | 10.50.100.6 | 10.0.10.3 +200 | 04001 | ansible-server | czp-infra-ansible-ctrl-prod-01| 10.0.1.100 | 10.0.1.10 +EOF +``` + +### Étape 3: Migration par Lots +```bash +# Lot 1: VMs non-critiques (dev/staging) +DRY_RUN=true migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 +# Valider sortie, puis: +migrate-vm.sh 104 10001 czp-t001-web-prod-01 10.0.10.1 + +# Lot 2: Services d'infrastructure +migrate-vm.sh 200 04001 czp-infra-ansible-ctrl-prod-01 10.0.1.10 + +# Lot 3: Services critiques (planifier fenêtre maintenance) +migrate-vm.sh 100 02001 czp-infra-dns-master-prod-01 10.0.2.10 +``` + +### Étape 4: Validation Post-Migration +```bash +# Vérifier conformité +audit-nomenclature.sh + +# Régénérer DNS +generate-dns-records.sh > /var/lib/alliance-boreale/dns-records.zone + +# Régénérer inventaire +generate-inventory.sh + +# Tester connectivité +ansible all -m ping -i /var/lib/alliance-boreale/inventory.yml +``` + +### Étape 5: Nettoyage +```bash +# Supprimer anciennes VMs (après validation complète) +qm destroy 104 +qm destroy 105 +qm destroy 200 + +# Archiver anciens backups +mv /var/lib/vz/dump/vzdump-qemu-104-*.zst /backup/archive/ +``` + +## Automatisation + +### Cron Job - Audit Quotidien +```bash +# /etc/cron.daily/audit-nomenclature +#!/bin/bash +/usr/local/bin/audit-nomenclature.sh > /var/log/alliance-boreale/audit-$(date +%Y%m%d).log 2>&1 +``` + +### Cron Job - Génération DNS Hebdomadaire +```bash +# /etc/cron.weekly/generate-dns +#!/bin/bash +/usr/local/bin/generate-dns-records.sh > /var/lib/alliance-boreale/dns-records.zone +/usr/local/bin/generate-inventory.sh +``` + +## Intégration CI/CD + +### GitLab CI - Validation Pre-Deployment +```yaml +# .gitlab-ci.yml +stages: + - validate + +validate_vmid: + stage: validate + script: + - validate-vmid.sh ${NEW_VMID} + only: + - merge_requests +``` + +## Troubleshooting + +### Problème: Audit échoue +```bash +# Vérifier que qm est accessible +qm list + +# Vérifier permissions +ls -la /usr/local/bin/audit-nomenclature.sh + +# Exécuter en mode debug +bash -x /usr/local/bin/audit-nomenclature.sh +``` + +### Problème: Migration échoue +```bash +# Vérifier espace disque +df -h + +# Vérifier état VM source +qm status + +# Consulter logs Proxmox +tail -f /var/log/pve/tasks/active +``` + +### Problème: IP déjà allouée +```bash +# Consulter IPAM +cat /etc/alliance-boreale/ipam.txt + +# Rechercher IP spécifique +grep "10.0.10.1" /etc/alliance-boreale/ipam.txt + +# Forcer allocation nouvelle plage +# Éditer manuellement ipam.txt +``` + +## Support + +**Documentation complète:** https://docs.alliance-boreale.ca/nomenclature-v2 +**Dépôt Git:** https://forge.alliance-boreale.ca/tools/nomenclature-scripts +**Contact:** technique@alliance-boreale.ca + +--- + +**Licence:** AGPL-3.0 +**Version:** 1.0 +**Dernière mise à jour:** 21 octobre 2025 +DOC + +################################################################################ +# FIN DU FICHIER +################################################################################ + +echo "" +echo "======================================================" +echo "SCRIPTS DE MIGRATION ET D'AUDIT - v1.0" +echo "L'Alliance Boréale" +echo "======================================================" +echo "" +echo "✅ 6 scripts créés:" +echo " 1. audit-nomenclature.sh" +echo " 2. generate-dns-records.sh" +echo " 3. generate-inventory.sh" +echo " 4. migrate-vm.sh" +echo " 5. validate-vmid.sh" +echo " 6. allocate-ip.sh" +echo "" +echo "✅ Script d'installation créé:" +echo " - install-nomenclature-tools.sh" +echo "" +echo "✅ Documentation créée:" +echo " - /usr/local/share/doc/nomenclature-v2-scripts.md" +echo "" +echo "Pour installer:" +echo " sudo bash install-nomenclature-tools.sh" +echo "" +echo "======================================================"TION: +# Collection de scripts pour auditer et migrer les VMs vers le standard v2.0 +# +# SCRIPTS INCLUS: +# 1. audit-nomenclature.sh - Audit de conformité +# 2. generate-dns-records.sh - Génération enregistrements DNS +# 3. generate-inventory.sh - Génération inventaire Ansible +# 4. migrate-vm.sh - Migration d'une VM +# 5. validate-vmid.sh - Validation format VMID +# 6. allocate-ip.sh - Allocation IP tenant +################################################################################ + +################################################################################ +# SCRIPT 1: audit-nomenclature.sh +# Vérifie la conformité des VMs au standard v2.0 +################################################################################ + +cat > /usr/local/bin/audit-nomenclature.sh << 'AUDIT_SCRIPT' +#!/bin/bash +# audit-nomenclature.sh - Audit de conformité nomenclature v2.0 + +set -euo pipefail + +# Configuration +MEMBER_ID="${MEMBER_ID:-czp}" +REPORT_FILE="/tmp/audit-nomenclature-$(date +%Y%m%d-%H%M%S).txt" +REPORT_CSV="/tmp/audit-nomenclature-$(date +%Y%m%d-%H%M%S).csv" + +# Couleurs +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Compteurs +TOTAL=0 +CONFORME=0 +NON_CONFORME=0 + +echo "======================================================" +echo "AUDIT DE CONFORMITÉ - NOMENCLATURE v2.0" +echo "Membre: ${MEMBER_ID}" +echo "Date: $(date)" +echo "======================================================" +echo "" + +# En-tête CSV +echo "VMID,Nom,IP,Conforme_VMID,Conforme_Nom,Conforme_IP,Statut_Global,Commentaires" > "$REPORT_CSV" + +# Fonction de validation VMID +validate_vmid() { + local vmid=$1 + + # Infrastructure: 0[1-4][0-9]{3} + if [[ $vmid =~ ^0[1-4][0-9]{3}$ ]]; then + echo "infra" + return 0 + fi + + # Tenant: [1-9][0-9]{4} + if [[ $vmid =~ ^[1-9][0-9]{4}$ ]]; then + echo "tenant" + return 0 + fi + + echo "invalid" + return 1 +} + +# Fonction de validation nom +validate_name() { + local name=$1 + local vmid_type=$2 + + if [ "$vmid_type" = "infra" ]; then + # Format: -infra--- + if [[ $name =~ ^[a-z]+-infra-[a-z0-9-]+-[a-z]+-[0-9]{2}$ ]]; then + return 0 + fi + elif [ "$vmid_type" = "tenant" ]; then + # Format: -t[0-9]{3}--- + if [[ $name =~ ^[a-z]+-t[0-9]{3}-[a-z0-9-]+-[a-z]+-[0-9]{2}$ ]]; then + return 0 + fi + fi + + return 1 +} + +# Fonction de validation IP +validate_ip() { + local ip=$1 + local vmid_type=$2 + + if [ "$vmid_type" = "infra" ]; then + # Infrastructure: 10.0.0.0 - 10.0.23.255 + if [[ $ip =~ ^10\.0\.(0|1|2|20|21|22|23)\. ]]; then + return 0 + fi + elif [ "$vmid_type" = "tenant" ]; then + # Tenant: 10.0.10.0/23 ou 10.0.128.0/17 + if [[ $ip =~ ^10\.0\.(10|11)\. ]] || [[ $ip =~ ^10\.0\.(12[8-9]|1[3-9][0-9]|2[0-4][0-9]|25[0-5])\. ]]; then + return 0 + fi + fi + + return 1 +} + +# Boucle sur toutes les VMs +for vmid in $(qm list | awk 'NR>1 {print $1}'); do + TOTAL=$((TOTAL + 1)) + + # Récupérer les informations + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || echo "NO_NAME") + ip=$(qm config "$vmid" 2>/dev/null | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/' || echo "NO_IP") + + # Validation + vmid_type=$(validate_vmid "$vmid" || echo "invalid") + + conforme_vmid="NON" + conforme_nom="NON" + conforme_ip="NON" + statut="❌ NON CONFORME" + commentaires="" + + if [ "$vmid_type" != "invalid" ]; then + conforme_vmid="OUI" + else + commentaires="${commentaires}VMID invalide; " + fi + + if validate_name "$name" "$vmid_type"; then + conforme_nom="OUI" + else + commentaires="${commentaires}Nom invalide; " + fi + + if validate_ip "$ip" "$vmid_type"; then + conforme_ip="OUI" + else + commentaires="${commentaires}IP invalide; " + fi + + # Statut global + if [ "$conforme_vmid" = "OUI" ] && [ "$conforme_nom" = "OUI" ] && [ "$conforme_ip" = "OUI" ]; then + statut="✅ CONFORME" + CONFORME=$((CONFORME + 1)) + else + NON_CONFORME=$((NON_CONFORME + 1)) + fi + + # Affichage + if [ "$statut" = "✅ CONFORME" ]; then + echo -e "${GREEN}${statut}${NC} | VMID: $vmid | Nom: $name | IP: $ip" + else + echo -e "${RED}${statut}${NC} | VMID: $vmid | Nom: $name | IP: $ip" + echo -e " ${YELLOW}→ ${commentaires}${NC}" + fi + + # Export CSV + echo "$vmid,$name,$ip,$conforme_vmid,$conforme_nom,$conforme_ip,$statut,$commentaires" >> "$REPORT_CSV" +done + +echo "" +echo "======================================================" +echo "RÉSUMÉ" +echo "======================================================" +echo "Total VMs : $TOTAL" +echo -e "${GREEN}Conformes : $CONFORME${NC}" +echo -e "${RED}Non conformes : $NON_CONFORME${NC}" +echo "" +echo "Taux de conformité: $(awk "BEGIN {printf \"%.1f\", ($CONFORME/$TOTAL)*100}")%" +echo "" +echo "Rapport détaillé: $REPORT_CSV" +echo "======================================================" + +# Exit code basé sur conformité +if [ "$NON_CONFORME" -gt 0 ]; then + exit 1 +else + exit 0 +fi +AUDIT_SCRIPT + +chmod +x /usr/local/bin/audit-nomenclature.sh + +################################################################################ +# SCRIPT 2: generate-dns-records.sh +# Génère les enregistrements DNS à partir de l'inventaire Proxmox +################################################################################ + +cat > /usr/local/bin/generate-dns-records.sh << 'DNS_SCRIPT' +#!/bin/bash +# generate-dns-records.sh - Génération enregistrements DNS + +set -euo pipefail + +# Configuration +MEMBER="${MEMBER_ID:-czp}" +DOMAIN="${DNS_DOMAIN:-alliance-boreale.ca}" +OUTPUT_FILE="${DNS_OUTPUT:-/tmp/dns-records-${MEMBER}.zone}" + +echo "; DNS Records for ${MEMBER}.${DOMAIN}" +echo "; Generated on $(date)" +echo "; Standard Nomenclature v2.0" +echo "" + +# Infrastructure (Couches 1-4) +echo "; ======================================================" +echo "; INFRASTRUCTURE (Couches 1-4)" +echo "; ======================================================" + +for vmid in $(qm list | grep -E "0[1-4][0-9]{3}" | awk '{print $1}'); do + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || continue) + ip=$(qm config "$vmid" 2>/dev/null | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/' || continue) + + # Extraire le service du nom + # Format: -infra--- + if [[ $name =~ ^[a-z]+-infra-([a-z0-9-]+)-([a-z]+)-([0-9]{2})$ ]]; then + service="${BASH_REMATCH[1]}" + env="${BASH_REMATCH[2]}" + instance="${BASH_REMATCH[3]}" + + # Nom DNS complet + if [ "$env" = "prod" ]; then + dns_name="${service}.infra.${MEMBER}.${DOMAIN}." + else + dns_name="${service}-${env}.infra.${MEMBER}.${DOMAIN}." + fi + + echo "$dns_name IN A $ip" + fi +done + +echo "" + +# Tenants (Couches 5-8) +echo "; ======================================================" +echo "; TENANTS (Couches 5-8)" +echo "; ======================================================" + +for vmid in $(qm list | grep -E "^[1-9][0-9]{4}$" | awk '{print $1}'); do + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || continue) + ip=$(qm config "$vmid" 2>/dev/null | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/' || continue) + + # Extraire tenant et service du nom + # Format: -t--- + if [[ $name =~ ^[a-z]+-(t[0-9]{3})-([a-z0-9-]+)-([a-z]+)-([0-9]{2})$ ]]; then + tenant="${BASH_REMATCH[1]}" + service="${BASH_REMATCH[2]}" + env="${BASH_REMATCH[3]}" + instance="${BASH_REMATCH[4]}" + + # Nom DNS complet + if [ "$env" = "prod" ]; then + dns_name="${service}.${tenant}.${MEMBER}.${DOMAIN}." + else + dns_name="${service}-${env}.${tenant}.${MEMBER}.${DOMAIN}." + fi + + echo "$dns_name IN A $ip" + fi +done + +echo "" +echo "; ======================================================" +echo "; END OF DNS RECORDS" +echo "; ======================================================" +DNS_SCRIPT + +chmod +x /usr/local/bin/generate-dns-records.sh + +################################################################################ +# SCRIPT 3: generate-inventory.sh +# Génère l'inventaire Ansible à partir de Proxmox +################################################################################ + +cat > /usr/local/bin/generate-inventory.sh << 'INVENTORY_SCRIPT' +#!/bin/bash +# generate-inventory.sh - Génération inventaire Ansible YAML + +set -euo pipefail + +# Configuration +MEMBER="${MEMBER_ID:-czp}" +DOMAIN="${DNS_DOMAIN:-alliance-boreale.ca}" +OUTPUT_FILE="${INVENTORY_OUTPUT:-/tmp/inventory-${MEMBER}.yml}" + +cat > "$OUTPUT_FILE" << YAML_HEADER +--- +# Ansible Inventory - ${MEMBER} +# Generated on $(date) +# Standard Nomenclature v2.0 + +all: + vars: + member_id: ${MEMBER} + domain: ${DOMAIN} + + children: + infrastructure: + vars: + category: infrastructure + + children: +YAML_HEADER + +# Générer les groupes par couche +for layer in 1 2 3 4; do + echo " layer_${layer}:" >> "$OUTPUT_FILE" + echo " hosts:" >> "$OUTPUT_FILE" + + has_hosts=false + for vmid in $(qm list | grep -E "^0${layer}[0-9]{3}$" | awk '{print $1}'); do + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || continue) + ip=$(qm config "$vmid" 2>/dev/null | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/' || continue) + + if [[ $name =~ ^[a-z]+-infra-([a-z0-9-]+)-([a-z]+)-([0-9]{2})$ ]]; then + service="${BASH_REMATCH[1]}" + env="${BASH_REMATCH[2]}" + + dns_name="${service}.infra.${MEMBER}.${DOMAIN}" + + cat >> "$OUTPUT_FILE" << YAML_HOST + ${dns_name}: + ansible_host: ${ip} + vmid: ${vmid} + layer: ${layer} + service: ${service} + environment: ${env} +YAML_HOST + has_hosts=true + fi + done + + if [ "$has_hosts" = false ]; then + echo " {}" >> "$OUTPUT_FILE" + fi + echo "" >> "$OUTPUT_FILE" +done + +# Générer les groupes tenants +echo " tenants:" >> "$OUTPUT_FILE" +echo " vars:" >> "$OUTPUT_FILE" +echo " category: tenant" >> "$OUTPUT_FILE" +echo " children:" >> "$OUTPUT_FILE" + +# Trouver tous les tenants uniques +tenant_ids=$(qm list | grep -E "^[1-9][0-9]{4}$" | awk '{print $1}' | while read vmid; do + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || continue) + if [[ $name =~ -(t[0-9]{3})- ]]; then + echo "${BASH_REMATCH[1]}" + fi +done | sort -u) + +for tenant_id in $tenant_ids; do + echo " tenant_${tenant_id}:" >> "$OUTPUT_FILE" + echo " vars:" >> "$OUTPUT_FILE" + echo " tenant_id: ${tenant_id}" >> "$OUTPUT_FILE" + echo " hosts:" >> "$OUTPUT_FILE" + + has_hosts=false + for vmid in $(qm list | grep -E "^[1-9][0-9]{4}$" | awk '{print $1}'); do + name=$(qm config "$vmid" 2>/dev/null | grep "^name:" | awk '{print $2}' || continue) + + if [[ $name =~ -(${tenant_id})-([a-z0-9-]+)-([a-z]+)-([0-9]{2})$ ]]; then + ip=$(qm config "$vmid" 2>/dev/null | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/' || continue) + service="${BASH_REMATCH[2]}" + env="${BASH_REMATCH[3]}" + + dns_name="${service}.${tenant_id}.${MEMBER}.${DOMAIN}" + + cat >> "$OUTPUT_FILE" << YAML_HOST + ${dns_name}: + ansible_host: ${ip} + vmid: ${vmid} + tenant: ${tenant_id} + service: ${service} + environment: ${env} +YAML_HOST + has_hosts=true + fi + done + + if [ "$has_hosts" = false ]; then + echo " {}" >> "$OUTPUT_FILE" + fi + echo "" >> "$OUTPUT_FILE" +done + +echo "Inventaire généré: $OUTPUT_FILE" +INVENTORY_SCRIPT + +chmod +x /usr/local/bin/generate-inventory.sh + +################################################################################ +# SCRIPT 4: migrate-vm.sh +# Migre une VM vers le nouveau standard +################################################################################ + +cat > /usr/local/bin/migrate-vm.sh << 'MIGRATE_SCRIPT' +#!/bin/bash +# migrate-vm.sh - Migration d'une VM vers nomenclature v2.0 + +set -euo pipefail + +# Configuration +MEMBER_ID="${MEMBER_ID:-czp}" +DRY_RUN="${DRY_RUN:-false}" + +# Couleurs +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' + +usage() { + echo "Usage: $0 " + echo "" + echo "Exemple:" + echo " $0 104 10001 czp-t001-web-prod-01 10.0.10.1" + echo "" + echo "Options:" + echo " DRY_RUN=true - Mode simulation (pas de changement)" + exit 1 +} + +# Vérification arguments +if [ $# -ne 4 ]; then + usage +fi + +VMID_SRC="$1" +VMID_DST="$2" +NEW_NAME="$3" +NEW_IP="$4" + +echo "======================================================" +echo "MIGRATION VM - NOMENCLATURE v2.0" +echo "======================================================" +echo "VMID source : $VMID_SRC" +echo "VMID dest : $VMID_DST" +echo "Nouveau nom : $NEW_NAME" +echo "Nouvelle IP : $NEW_IP" +echo "Mode simulation: $DRY_RUN" +echo "======================================================" +echo "" + +# Vérifier que la VM source existe +if ! qm status "$VMID_SRC" &>/dev/null; then + echo -e "${RED}ERREUR: VM $VMID_SRC n'existe pas${NC}" + exit 1 +fi + +# Vérifier que la VM dest n'existe pas +if qm status "$VMID_DST" &>/dev/null; then + echo -e "${RED}ERREUR: VM $VMID_DST existe déjà${NC}" + exit 1 +fi + +# Récupérer info actuelle +OLD_NAME=$(qm config "$VMID_SRC" | grep "^name:" | awk '{print $2}') +OLD_IP=$(qm config "$VMID_SRC" | grep "ipconfig0" | sed 's/.*ip=\([^,/]*\).*/\1/') + +echo -e "${YELLOW}État actuel:${NC}" +echo " Nom: $OLD_NAME" +echo " IP : $OLD_IP" +echo "" +echo -e "${GREEN}Nouvel état:${NC}" +echo " Nom: $NEW_NAME" +echo " IP : $NEW_IP" +echo "" + +# Demander confirmation +if [ "$DRY_RUN" != "true" ]; then + read -p "Continuer? (oui/non): " confirm + if [ "$confirm" != "oui" ]; then + echo "Migration annulée" + exit 0 + fi +fi + +echo "" +echo "Étapes de migration:" +echo "" + +# Étape 1: Backup +echo "1. Création backup..." +if [ "$DRY_RUN" != "true" ]; then + vzdump "$VMID_SRC" --mode snapshot --compress zstd --storage local + echo -e "${GREEN} ✓ Backup créé${NC}" +else + echo -e "${YELLOW} [SIMULATION] Backup créé${NC}" +fi + +# Étape 2: Arrêter la VM +echo "2. Arrêt de la VM..." +if [ "$DRY_RUN" != "true" ]; then + qm shutdown "$VMID_SRC" || qm stop "$VMID_SRC" + sleep 5 + echo -e "${GREEN} ✓ VM arrêtée${NC}" +else + echo -e "${YELLOW} [SIMULATION] VM arrêtée${NC}" +fi + +# Étape 3: Cloner avec nouveau VMID +echo "3. Clonage vers nouveau VMID..." +if [ "$DRY_RUN" != "true" ]; then + qm clone "$VMID_SRC" "$VMID_DST" --name "$NEW_NAME" --full + echo -e "${GREEN} ✓ VM clonée${NC}" +else + echo -e "${YELLOW} [SIMULATION] VM clonée${NC}" +fi + +# Étape 4: Changer l'IP +echo "4. Configuration nouvelle IP..." +if [ "$DRY_RUN" != "true" ]; then + # Modifier la config réseau Proxmox + qm set "$VMID_DST" --ipconfig0 "ip=${NEW_IP}/24,gw=10.0.0.1" + echo -e "${GREEN} ✓ IP configurée dans Proxmox${NC}" + echo -e "${YELLOW} ⚠ ATTENTION: Modifier aussi l'IP dans la VM (après démarrage)${NC}" +else + echo -e "${YELLOW} [SIMULATION] IP configurée${NC}" +fi + +# Étape 5: Démarrer la nouvelle VM +echo "5. Démarrage nouvelle VM..." +if [ "$DRY_RUN" != "true" ]; then + qm start "$VMID_DST" + echo -e "${GREEN} ✓ VM démarrée${NC}" +else + echo -e "${YELLOW} [SIMULATION] VM démarrée${NC}" +fi + +echo "" +echo "======================================================" +echo "MIGRATION TERMINÉE" +echo "======================================================" +echo "" +echo "Prochaines étapes MANUELLES:" +echo "1. Vérifier que la VM démarre correctement" +echo "2. Connecter à la VM et changer l'IP dans /etc/network/interfaces" +echo "3. Tester la connectivité réseau" +echo "4. Créer l'entrée DNS: ${NEW_NAME%.prod-*}.infra.${MEMBER_ID}.alliance-boreale.ca" +echo "5. Mettre à jour l'inventaire Ansible" +echo "6. Mettre à jour le monitoring" +echo "7. Une fois validé, supprimer l'ancienne VM: qm destroy $VMID_SRC" +echo "" +MIGRATE_SCRIPT + +chmod +x /usr/local/bin/migrate-vm.sh + +################################################################################ +# SCRIPT 5: validate-vmid.sh +# Valide le format d'un VMID +################################################################################ + +cat > /usr/local/bin/validate-vmid.sh << 'VALIDATE_SCRIPT' +#!/bin/bash +# validate-vmid.sh - Validation format VMID + +set -euo pipefail + +usage() { + echo "Usage: $0 " + echo "" + echo "Valide qu'un VMID respecte le standard v2.0" + echo "" + echo "Exemples:" + echo " $0 02001 # Infrastructure Couche 2" + echo " $0 10001 # Tenant 001" + exit 1 +} + +if [ $# -ne 1 ]; then + usage +fi + +VMID="$1" + +# Infrastructure: 0[1-4][0-9]{3} +if [[ $VMID =~ ^0[1-4][0-9]{3}$ ]]; then + layer="${VMID:1:1}" + type="${VMID:2:2}" + instance="${VMID:4:2}" + + echo "✅ VMID VALIDE" + echo "Type: Infrastructure" + echo "Couche: $layer" + echo "Type service: $type" + echo "Instance: $instance" + + case $layer in + 1) echo "Description: Couche 1 - Physique" ;; + 2) echo "Description: Couche 2 - Réseau" ;; + 3) echo "Description: Couche 3 - Stockage" ;; + 4) echo "Description: Couche 4 - Orchestration" ;; + esac + + exit 0 +fi + +# Tenant: [1-9][0-9]{4} +if [[ $VMID =~ ^[1-9][0-9]{4}$ ]]; then + tenant="${VMID:0:3}" + instance="${VMID:3:2}" + + echo "✅ VMID VALIDE" + echo "Type: Tenant" + echo "Tenant ID: $tenant" + echo "Instance: $instance" + + exit 0 +fi + +# Invalide +echo "❌ VMID INVALIDE" +echo "" +echo "Format attendu:" +echo " Infrastructure: 0CTTII (ex: 02001)" +echo " 0 = Infrastructure" +echo " C = Couche (1-4)" +echo " TT = Type (00-99)" +echo " II = Instance (01-99)" +echo "" +echo " Tenant: TTTII (ex: 10001)" +echo " TTT = Tenant ID (001-999)" +echo " II = Instance (01-99)" +exit 1 +VALIDATE_SCRIPT + +chmod +x /usr/local/bin/validate-vmid.sh + +################################################################################ +# SCRIPT 6: allocate-ip.sh +# Alloue une IP pour un nouveau tenant +################################################################################ + +cat > /usr/local/bin/allocate-ip.sh << 'ALLOCATE_SCRIPT' +#!/bin/bash +# allocate-ip.sh - Allocation IP tenant + +set -euo pipefail + +# Configuration +IPAM_FILE="${IPAM_FILE:-/etc/alliance-boreale/ipam.txt}" + +usage() { + echo "Usage: $0 " + echo "" + echo "Alloue la prochaine IP disponible pour un tenant" + echo "" + echo "Exemple:" + echo " $0 001 # Alloue IP pour tenant 001" + exit 1 +} + +if [ $# -ne 1 ]; then + usage +fi + +TENANT_ID="$1" + +# Vérifier format tenant ID +if ! [[ $TENANT_ID =~ ^[0-9]{3}$ ]]; then + echo "ERREUR: Tenant ID doit être au format NNN (ex: 001)" + exit 1 +fi + +# Créer fichier IPAM si inexistant +if [ ! -f "$IPAM_FILE" ]; then + mkdir -p "$(dirname "$IPAM_FILE")" + echo "# IPAM - Tenant IP Allocation" > "$IPAM_FILE" + echo "# Format: TENANT_ID IP DATE VMID" >> "$IPAM_FILE" +fi + +# Vérifier si tenant a déjà des IPs +existing_ips=$(grep "^$TENANT_ID " "$IPAM_FILE" 2>/dev/null || true) + +if [ -n "$existing_ips" ]; then + echo "Tenant $TENANT_ID a déjà des IPs allouées:" + echo "$existing_ips" + echo "" +fi + +# Trouver prochaine IP disponible dans 10.0.10.0/23 +# Stratégie: 10.0.10.0-99 pour tenant 001, 10.0.10.100-199 pour tenant 002, etc. + +base_ip_part=$((10 + (${TENANT_ID#0} * 100) / 1000)) +base_host=$((((${TENANT_ID#0} % 10) * 100))) + +# Trouver prochaine IP libre +for i in {1..99}; do + test_ip="10.0.${base_ip_part}.$((base_host + i))" + + # Vérifier si IP déjà allouée + if ! grep -q " ${test_ip} " "$IPAM_FILE" 2>/dev/null; then + echo "✅ IP DISPONIBLE: $test_ip" + echo "" + echo "Pour allouer cette IP:" + echo " echo \"$TENANT_ID $test_ip $(date +%Y-%m-%d) VMID\" >> $IPAM_FILE" + exit 0 + fi +done + +echo "❌ ERREUR: Aucune IP disponible pour le tenant $TENANT_ID" +echo "Considérer utiliser la plage d'expansion 10.0.128.0/17" +exit 1 +ALLOCATE_SCRIPT + +chmod +x /usr/local/bin/allocate-ip.sh + +################################################################################ +# Installation et Configuration +################################################################################ + +echo "#!/bin/bash" > /usr/local/bin/install-nomenclature-tools.sh +cat >> /usr/local/bin/install-nomenclature-tools.sh << 'INSTALL' +# install-nomenclature-tools.sh - Installation des outils nomenclature v2.0 + +set -euo pipefail + +echo "======================================================" +echo "INSTALLATION OUTILS NOMENCLATURE v2.0" +echo "L'Alliance Boréale" +echo "======================================================" +echo "" + +# Vérifier droits root +if [ "$EUID" -ne 0 ]; then + echo "ERREUR: Ce script doit être exécuté en root" + exit 1 +fi + +# Configuration +read -p "ID du membre (ex: czp): " MEMBER_ID +read -p "Domaine DNS (ex: alliance-boreale.ca): " DNS_DOMAIN + +# Créer fichier de configuration +mkdir -p /etc/alliance-boreale +cat > /etc/alliance-boreale/nomenclature.conf << CONFIG +# Configuration Nomenclature v2.0 +MEMBER_ID="${MEMBER_ID}" +DNS_DOMAIN="${DNS_DOMAIN}" +IP \ No newline at end of file diff --git a/docs/architecture/templates_automation.md b/docs/architecture/templates_automation.md new file mode 100644 index 0000000..2341392 --- /dev/null +++ b/docs/architecture/templates_automation.md @@ -0,0 +1,968 @@ +# Templates Ansible & Terraform - Nomenclature v2.0 +# L'Alliance Boréale +# +# Version: 1.0 +# Date: 21 octobre 2025 +# Licence: AGPL-3.0 + +################################################################################ +# PARTIE 1: TEMPLATES ANSIBLE +################################################################################ + +# ============================================================================== +# 1. Inventaire Dynamique Proxmox +# ============================================================================== + +# inventory/proxmox.yml +--- +plugin: community.general.proxmox +url: https://proxmox.example.com:8006 +user: ansible@pve +password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + ... +validate_certs: no + +# Grouper automatiquement par tags +compose: + ansible_host: proxmox_ipconfig0.ip | regex_replace('/.*', '') + +keyed_groups: + # Grouper par couche (infrastructure) + - prefix: layer + key: proxmox_tags | select('match', '^layer-[1-4]$') | first | default('unknown') + + # Grouper par tenant + - prefix: tenant + key: proxmox_tags | select('match', '^tenant-t[0-9]{3}$') | first | default('none') + + # Grouper par environnement + - prefix: env + key: proxmox_tags | select('match', '^(prod|stg|dev|test)$') | first | default('unknown') + + # Grouper par catégorie + - prefix: category + key: proxmox_tags | select('match', '^(infrastructure|tenant)$') | first | default('unknown') + +# ============================================================================== +# 2. Playbook de Création VM Infrastructure +# ============================================================================== + +# playbooks/create-infra-vm.yml +--- +- name: Créer VM Infrastructure selon nomenclature v2.0 + hosts: localhost + gather_facts: no + + vars_prompt: + - name: vm_layer + prompt: "Couche (1-4)" + private: no + + - name: vm_type + prompt: "Type service (ex: 00=DNS, 10=VPN, 20=Git)" + private: no + + - name: vm_instance + prompt: "Instance (01-99)" + private: no + + - name: vm_service_name + prompt: "Nom du service (ex: dns-master, ansible-ctrl)" + private: no + + - name: vm_environment + prompt: "Environnement (prod/stg/dev/test)" + private: no + default: "prod" + + vars: + member_id: "{{ lookup('env', 'MEMBER_ID') | default('czp', true) }}" + + # Calcul VMID + vmid: "{{ '%s%02d' | format(tenant_id, vm_instance|int) }}" + + # Construction nom VM + vm_name: "{{ member_id }}-t{{ tenant_id }}-{{ vm_service_type }}-{{ vm_environment }}-{{ '%02d' | format(vm_instance|int) }}" + + # Allocation IP (via script ou manuel) + vm_ip: "{{ lookup('pipe', 'allocate-ip.sh ' + tenant_id) | regex_search('\\d+\\.\\d+\\.\\d+\\.\\d+') }}" + + # DNS + vm_dns: "{{ vm_service_type }}.t{{ tenant_id }}.{{ member_id }}.alliance-boreale.ca" + + tasks: + - name: Afficher plan de création + debug: + msg: + - "VMID: {{ vmid }}" + - "Nom: {{ vm_name }}" + - "IP: {{ vm_ip }}/23" + - "DNS: {{ vm_dns }}" + - "Tenant: {{ tenant_id }}" + + - name: Confirmer création + pause: + prompt: "Créer cette VM? (Ctrl+C pour annuler)" + + - name: Créer VM dans Proxmox + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + node: "{{ proxmox_node }}" + + vmid: "{{ vmid }}" + name: "{{ vm_name }}" + + clone: "{{ vm_template | default('debian-12-template') }}" + full: yes + + cores: "{{ vm_cores | default(2) }}" + memory: "{{ vm_memory | default(2048) }}" + + net: + net0: "virtio,bridge=vmbr0,tag=10" + + ipconfig: + ipconfig0: "ip={{ vm_ip }}/23,gw=10.0.0.1" + + tags: + - tenant + - "tenant-t{{ tenant_id }}" + - "{{ vm_environment }}" + - "service-{{ vm_service_type }}" + + state: present + + - name: Enregistrer IP dans IPAM + ansible.builtin.lineinfile: + path: "/etc/alliance-boreale/ipam.txt" + line: "{{ tenant_id }} {{ vm_ip }} {{ ansible_date_time.date }} {{ vmid }}" + create: yes + + - name: Créer entrée DNS + ansible.builtin.lineinfile: + path: "/var/lib/alliance-boreale/dns-records.zone" + line: "{{ vm_dns }}. IN A {{ vm_ip }}" + delegate_to: "{{ dns_master_host }}" + + - name: Démarrer la VM + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + vmid: "{{ vmid }}" + state: started + +# ============================================================================== +# 4. Role Ansible - Conformité Nomenclature +# ============================================================================== + +# roles/nomenclature_compliance/tasks/main.yml +--- +- name: Vérifier que le VMID est conforme + ansible.builtin.assert: + that: + - inventory_hostname_short | regex_search('^[a-z]+-((infra)|(t[0-9]{3}))-') + fail_msg: "Nom VM non conforme au standard v2.0" + success_msg: "Nom VM conforme" + +- name: Extraire les informations de nomenclature + ansible.builtin.set_fact: + vm_member: "{{ inventory_hostname_short | regex_replace('^([a-z]+)-.*', '\\1') }}" + vm_category: "{{ 'infrastructure' if 'infra' in inventory_hostname_short else 'tenant' }}" + vm_tenant_id: "{{ inventory_hostname_short | regex_replace('.*-(t[0-9]{3})-.*', '\\1') if 'infra' not in inventory_hostname_short else 'N/A' }}" + +- name: Afficher informations extraites + debug: + msg: + - "Membre: {{ vm_member }}" + - "Catégorie: {{ vm_category }}" + - "Tenant: {{ vm_tenant_id }}" + +- name: Vérifier cohérence IP + ansible.builtin.assert: + that: + - ansible_default_ipv4.address | regex_search('^10\\.0\\.') + fail_msg: "IP hors de la plage 10.0.0.0/8" + success_msg: "IP dans la plage correcte" + +- name: Appliquer tags de conformité + ansible.builtin.set_fact: + nomenclature_compliant: true + nomenclature_version: "v2.0" + nomenclature_validated_date: "{{ ansible_date_time.iso8601 }}" + +# ============================================================================== +# 5. Playbook d'Audit Ansible +# ============================================================================== + +# playbooks/audit-nomenclature-ansible.yml +--- +- name: Audit de conformité Nomenclature v2.0 via Ansible + hosts: all + gather_facts: yes + + tasks: + - name: Vérifier nom VM + ansible.builtin.set_fact: + name_compliant: "{{ inventory_hostname_short | regex_search('^[a-z]+-(infra|t[0-9]{3})-[a-z0-9-]+-[a-z]+-[0-9]{2} + + vars: + member_id: "{{ lookup('env', 'MEMBER_ID') | default('czp', true) }}" + + # Calcul VMID + vmid: "{{ '0%s%02d%02d' | format(vm_layer, vm_type|int, vm_instance|int) }}" + + # Construction nom VM + vm_name: "{{ member_id }}-infra-{{ vm_service_name }}-{{ vm_environment }}-{{ '%02d' | format(vm_instance|int) }}" + + # Calcul IP selon couche + vm_ip: >- + {{ + ('10.0.0.' if vm_layer == '1' else + '10.0.1.' if vm_layer == '4' else + '10.0.2.' if vm_layer == '2' else + '10.0.3.') + (vm_type|int * 10 + vm_instance|int)|string + }} + + # DNS + vm_dns: "{{ vm_service_name }}.infra.{{ member_id }}.alliance-boreale.ca" + + tasks: + - name: Afficher plan de création + debug: + msg: + - "VMID: {{ vmid }}" + - "Nom: {{ vm_name }}" + - "IP: {{ vm_ip }}/24" + - "DNS: {{ vm_dns }}" + + - name: Confirmer création + pause: + prompt: "Créer cette VM? (Ctrl+C pour annuler, Entrée pour continuer)" + + - name: Créer VM dans Proxmox + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + node: "{{ proxmox_node }}" + + vmid: "{{ vmid }}" + name: "{{ vm_name }}" + + clone: "debian-12-template" + full: yes + + cores: 2 + memory: 2048 + + net: + net0: "virtio,bridge=vmbr0,tag={{ '2' if vm_layer == '2' else '1' }}" + + ipconfig: + ipconfig0: "ip={{ vm_ip }}/24,gw=10.0.0.1" + + tags: + - infrastructure + - "layer-{{ vm_layer }}" + - "{{ vm_environment }}" + - "service-{{ vm_service_name }}" + + state: present + register: vm_created + + - name: Démarrer la VM + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + vmid: "{{ vmid }}" + state: started + + - name: Créer entrée DNS + ansible.builtin.lineinfile: + path: "/var/lib/alliance-boreale/dns-records.zone" + line: "{{ vm_dns }}. IN A {{ vm_ip }}" + create: yes + delegate_to: "{{ dns_master_host }}" + + - name: Ajouter au monitoring + ansible.builtin.template: + src: templates/icinga2-host.conf.j2 + dest: "/etc/icinga2/conf.d/hosts/{{ vm_name }}.conf" + delegate_to: "{{ monitoring_host }}" + notify: Reload Icinga2 + +# ============================================================================== +# 3. Playbook de Création VM Tenant +# ============================================================================== + +# playbooks/create-tenant-vm.yml +--- +- name: Créer VM Tenant selon nomenclature v2.0 + hosts: localhost + gather_facts: no + + vars_prompt: + - name: tenant_id + prompt: "Tenant ID (001-999)" + private: no + + - name: vm_instance + prompt: "Instance (01-99)" + private: no + + - name: vm_service_type + prompt: "Type (web/api/db/cache/worker)" + private: no + + - name: vm_environment + prompt: "Environnement (prod/stg/dev) is not none }}" + + - name: Vérifier IP dans plage correcte + ansible.builtin.set_fact: + ip_compliant: "{{ ansible_default_ipv4.address | regex_search('^10\\.0\\.') is not none }}" + + - name: Extraire VMID si possible + ansible.builtin.shell: | + qm list | awk -v host="{{ inventory_hostname_short }}" '$2 == host {print $1}' + register: vmid_check + delegate_to: "{{ proxmox_node }}" + changed_when: false + failed_when: false + + - name: Valider VMID + ansible.builtin.command: validate-vmid.sh {{ vmid_check.stdout }} + register: vmid_validation + delegate_to: localhost + changed_when: false + failed_when: false + when: vmid_check.stdout != "" + + - name: Générer rapport + ansible.builtin.set_fact: + compliance_report: + hostname: "{{ inventory_hostname }}" + name_compliant: "{{ name_compliant }}" + ip_compliant: "{{ ip_compliant }}" + vmid: "{{ vmid_check.stdout | default('N/A') }}" + vmid_compliant: "{{ vmid_validation.rc == 0 if vmid_check.stdout != '' else false }}" + overall_compliant: "{{ name_compliant and ip_compliant and (vmid_validation.rc == 0 if vmid_check.stdout != '' else false) }}" + + - name: Afficher résultat + ansible.builtin.debug: + var: compliance_report + + - name: Sauvegarder rapport + ansible.builtin.copy: + content: "{{ compliance_report | to_nice_json }}" + dest: "/var/lib/alliance-boreale/compliance/{{ inventory_hostname }}.json" + delegate_to: localhost + +################################################################################ +# PARTIE 2: TEMPLATES TERRAFORM +################################################################################ + +# ============================================================================== +# 6. Module Terraform - VM Infrastructure +# ============================================================================== + +# modules/infra-vm/main.tf +terraform { + required_providers { + proxmox = { + source = "telmate/proxmox" + version = "~> 2.9" + } + } +} + +variable "member_id" { + description = "ID du membre (ex: czp, nul, tli)" + type = string +} + +variable "layer" { + description = "Couche (1-4)" + type = number + validation { + condition = var.layer >= 1 && var.layer <= 4 + error_message = "La couche doit être entre 1 et 4." + } +} + +variable "service_type" { + description = "Type de service (00-99)" + type = number +} + +variable "instance" { + description = "Numéro d'instance (01-99)" + type = number +} + +variable "service_name" { + description = "Nom du service (ex: dns-master, ansible-ctrl)" + type = string +} + +variable "environment" { + description = "Environnement (prod/stg/dev/test)" + type = string + default = "prod" +} + +variable "cores" { + description = "Nombre de CPU cores" + type = number + default = 2 +} + +variable "memory" { + description = "RAM en MB" + type = number + default = 2048 +} + +variable "disk_size" { + description = "Taille disque en GB" + type = string + default = "20G" +} + +# Calculs locaux +locals { + # VMID: 0CTTII + vmid = format("0%d%02d%02d", var.layer, var.service_type, var.instance) + + # Nom VM: -infra--- + vm_name = format("%s-infra-%s-%s-%02d", + var.member_id, + var.service_name, + var.environment, + var.instance + ) + + # IP selon couche + ip_base = var.layer == 1 ? "10.0.0" : ( + var.layer == 2 ? "10.0.2" : ( + var.layer == 3 ? "10.0.3" : "10.0.1")) + + vm_ip = format("%s.%d", local.ip_base, var.service_type * 10 + var.instance) + + # DNS + vm_dns = format("%s.infra.%s.alliance-boreale.ca", + var.service_name, + var.member_id + ) +} + +resource "proxmox_vm_qemu" "infra_vm" { + name = local.vm_name + vmid = local.vmid + target_node = var.proxmox_node + + clone = "debian-12-template" + full_clone = true + + cores = var.cores + memory = var.memory + + network { + model = "virtio" + bridge = "vmbr0" + tag = var.layer == 2 ? 2 : 1 + } + + disk { + type = "scsi" + storage = "local-lvm" + size = var.disk_size + } + + ipconfig0 = "ip=${local.vm_ip}/24,gw=10.0.0.1" + + tags = join(";", [ + "infrastructure", + "layer-${var.layer}", + var.environment, + "service-${var.service_name}", + "nomenclature-v2" + ]) + + lifecycle { + ignore_changes = [ + network, + ] + } +} + +output "vmid" { + value = local.vmid +} + +output "vm_name" { + value = local.vm_name +} + +output "vm_ip" { + value = local.vm_ip +} + +output "vm_dns" { + value = local.vm_dns +} + +# ============================================================================== +# 7. Module Terraform - VM Tenant +# ============================================================================== + +# modules/tenant-vm/main.tf +terraform { + required_providers { + proxmox = { + source = "telmate/proxmox" + version = "~> 2.9" + } + } +} + +variable "member_id" { + description = "ID du membre" + type = string +} + +variable "tenant_id" { + description = "Tenant ID (001-999)" + type = string + validation { + condition = can(regex("^[0-9]{3}$", var.tenant_id)) + error_message = "Tenant ID doit être au format NNN (ex: 001)." + } +} + +variable "instance" { + description = "Numéro d'instance (01-99)" + type = number +} + +variable "service_type" { + description = "Type de service (web/api/db/cache/worker)" + type = string +} + +variable "environment" { + description = "Environnement" + type = string + default = "prod" +} + +variable "ip_address" { + description = "Adresse IP (optionnel, auto-alloué si vide)" + type = string + default = "" +} + +variable "cores" { + type = number + default = 2 +} + +variable "memory" { + type = number + default = 2048 +} + +locals { + # VMID: TTTII + vmid = format("%s%02d", var.tenant_id, var.instance) + + # Nom VM + vm_name = format("%s-t%s-%s-%s-%02d", + var.member_id, + var.tenant_id, + var.service_type, + var.environment, + var.instance + ) + + # IP (utiliser celle fournie ou calculer) + vm_ip = var.ip_address != "" ? var.ip_address : format("10.0.10.%d", + (tonumber(var.tenant_id) - 1) * 10 + var.instance + ) + + # DNS + vm_dns = format("%s.t%s.%s.alliance-boreale.ca", + var.service_type, + var.tenant_id, + var.member_id + ) +} + +resource "proxmox_vm_qemu" "tenant_vm" { + name = local.vm_name + vmid = local.vmid + target_node = var.proxmox_node + + clone = var.vm_template + full_clone = true + + cores = var.cores + memory = var.memory + + network { + model = "virtio" + bridge = "vmbr0" + tag = 10 + } + + disk { + type = "scsi" + storage = "local-lvm" + size = var.disk_size + } + + ipconfig0 = "ip=${local.vm_ip}/23,gw=10.0.0.1" + + tags = join(";", [ + "tenant", + "tenant-t${var.tenant_id}", + var.environment, + "service-${var.service_type}", + "nomenclature-v2" + ]) +} + +# Enregistrer dans IPAM +resource "null_resource" "register_ipam" { + provisioner "local-exec" { + command = "echo '${var.tenant_id} ${local.vm_ip} ${timestamp()} ${local.vmid}' >> /etc/alliance-boreale/ipam.txt" + } + + depends_on = [proxmox_vm_qemu.tenant_vm] +} + +output "vmid" { + value = local.vmid +} + +output "vm_name" { + value = local.vm_name +} + +output "vm_ip" { + value = local.vm_ip +} + +output "vm_dns" { + value = local.vm_dns +} + +# ============================================================================== +# 8. Exemple d'Utilisation Terraform +# ============================================================================== + +# main.tf - Exemple de déploiement complet +terraform { + required_version = ">= 1.0" + + required_providers { + proxmox = { + source = "telmate/proxmox" + version = "~> 2.9" + } + } +} + +provider "proxmox" { + pm_api_url = var.proxmox_api_url + pm_user = var.proxmox_user + pm_password = var.proxmox_password + pm_tls_insecure = true +} + +variable "proxmox_api_url" {} +variable "proxmox_user" {} +variable "proxmox_password" {} +variable "proxmox_node" { default = "pve1" } +variable "member_id" { default = "czp" } + +# Infrastructure minimale Bronze +module "dns_master" { + source = "./modules/infra-vm" + + member_id = var.member_id + layer = 2 + service_type = 0 # DNS + instance = 1 + service_name = "dns-master" + + cores = 2 + memory = 4096 +} + +module "ansible_controller" { + source = "./modules/infra-vm" + + member_id = var.member_id + layer = 4 + service_type = 0 # Ansible + instance = 1 + service_name = "ansible-ctrl" +} + +module "backup_server" { + source = "./modules/infra-vm" + + member_id = var.member_id + layer = 3 + service_type = 30 # Backup + instance = 1 + service_name = "pbs-backup" + + cores = 4 + memory = 8192 + disk_size = "500G" +} + +# Premier tenant - Stack complète +module "tenant001_web" { + source = "./modules/tenant-vm" + + member_id = var.member_id + tenant_id = "001" + instance = 1 + service_type = "web" +} + +module "tenant001_api" { + source = "./modules/tenant-vm" + + member_id = var.member_id + tenant_id = "001" + instance = 11 + service_type = "api-fastapi" +} + +module "tenant001_db" { + source = "./modules/tenant-vm" + + member_id = var.member_id + tenant_id = "001" + instance = 21 + service_type = "db-postgres" + + cores = 4 + memory = 8192 +} + +# Outputs +output "infrastructure" { + value = { + dns_master = { + vmid = module.dns_master.vmid + name = module.dns_master.vm_name + ip = module.dns_master.vm_ip + dns = module.dns_master.vm_dns + } + ansible = { + vmid = module.ansible_controller.vmid + name = module.ansible_controller.vm_name + ip = module.ansible_controller.vm_ip + dns = module.ansible_controller.vm_dns + } + } +} + +output "tenant_001" { + value = { + web = module.tenant001_web + api = module.tenant001_api + db = module.tenant001_db + } +} + +# ============================================================================== +# 9. Variables Terraform +# ============================================================================== + +# variables.tf +variable "member_id" { + description = "ID du membre de L'Alliance Boréale" + type = string + + validation { + condition = can(regex("^[a-z]{2,4}$", var.member_id)) + error_message = "member_id doit être 2-4 lettres minuscules." + } +} + +variable "proxmox_node" { + description = "Nœud Proxmox cible" + type = string + default = "pve1" +} + +variable "dns_domain" { + description = "Domaine DNS de L'Alliance" + type = string + default = "alliance-boreale.ca" +} + +variable "vm_template" { + description = "Template VM par défaut" + type = string + default = "debian-12-template" +} + +# ============================================================================== +# 10. Makefile pour Automatisation +# ============================================================================== + +# Makefile +.PHONY: help audit migrate plan apply destroy + +help: + @echo "Commandes disponibles:" + @echo " make audit - Audit de conformité" + @echo " make plan - Plan Terraform" + @echo " make apply - Appliquer Terraform" + @echo " make destroy - Détruire infrastructure Terraform" + @echo " make ansible - Exécuter playbooks Ansible" + +audit: + @echo "=== Audit Nomenclature v2.0 ===" + audit-nomenclature.sh + ansible-playbook playbooks/audit-nomenclature-ansible.yml + +plan: + terraform plan -out=tfplan + +apply: + terraform apply tfplan + +destroy: + terraform destroy + +ansible: + ansible-playbook playbooks/configure-all.yml -i inventory/proxmox.yml + +# ============================================================================== +# FIN DES TEMPLATES +# ============================================================================== + + vars: + member_id: "{{ lookup('env', 'MEMBER_ID') | default('czp', true) }}" + + # Calcul VMID + vmid: "{{ '0%s%02d%02d' | format(vm_layer, vm_type|int, vm_instance|int) }}" + + # Construction nom VM + vm_name: "{{ member_id }}-infra-{{ vm_service_name }}-{{ vm_environment }}-{{ '%02d' | format(vm_instance|int) }}" + + # Calcul IP selon couche + vm_ip: >- + {{ + ('10.0.0.' if vm_layer == '1' else + '10.0.1.' if vm_layer == '4' else + '10.0.2.' if vm_layer == '2' else + '10.0.3.') + (vm_type|int * 10 + vm_instance|int)|string + }} + + # DNS + vm_dns: "{{ vm_service_name }}.infra.{{ member_id }}.alliance-boreale.ca" + + tasks: + - name: Afficher plan de création + debug: + msg: + - "VMID: {{ vmid }}" + - "Nom: {{ vm_name }}" + - "IP: {{ vm_ip }}/24" + - "DNS: {{ vm_dns }}" + + - name: Confirmer création + pause: + prompt: "Créer cette VM? (Ctrl+C pour annuler, Entrée pour continuer)" + + - name: Créer VM dans Proxmox + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + node: "{{ proxmox_node }}" + + vmid: "{{ vmid }}" + name: "{{ vm_name }}" + + clone: "debian-12-template" + full: yes + + cores: 2 + memory: 2048 + + net: + net0: "virtio,bridge=vmbr0,tag={{ '2' if vm_layer == '2' else '1' }}" + + ipconfig: + ipconfig0: "ip={{ vm_ip }}/24,gw=10.0.0.1" + + tags: + - infrastructure + - "layer-{{ vm_layer }}" + - "{{ vm_environment }}" + - "service-{{ vm_service_name }}" + + state: present + register: vm_created + + - name: Démarrer la VM + community.general.proxmox_kvm: + api_host: "{{ proxmox_host }}" + api_user: "{{ proxmox_user }}" + api_password: "{{ proxmox_password }}" + vmid: "{{ vmid }}" + state: started + + - name: Créer entrée DNS + ansible.builtin.lineinfile: + path: "/var/lib/alliance-boreale/dns-records.zone" + line: "{{ vm_dns }}. IN A {{ vm_ip }}" + create: yes + delegate_to: "{{ dns_master_host }}" + + - name: Ajouter au monitoring + ansible.builtin.template: + src: templates/icinga2-host.conf.j2 + dest: "/etc/icinga2/conf.d/hosts/{{ vm_name }}.conf" + delegate_to: "{{ monitoring_host }}" + notify: Reload Icinga2 + +# ============================================================================== +# 3. Playbook de Création VM Tenant +# ============================================================================== + +# playbooks/create-tenant-vm.yml +--- +- name: Créer VM Tenant selon nomenclature v2.0 + hosts: localhost + gather_facts: no + + vars_prompt: + - name: tenant_id + prompt: "Tenant ID (001-999)" + private: no + + - name: vm_instance + prompt: "Instance (01-99)" + private: no + + - name: vm_service_type + prompt: "Type (web/api/db/cache/worker)" + private: no + + - name: vm_environment + prompt: "Environnement (prod/stg/dev \ No newline at end of file