# AGENTS.md - Instructions pour Mistral Vibe et autres agents ## 🎯 Workflow DevOps Homelab ### ✅ RÈGLES FONDAMENTALES 1. **TOUJOURS travailler depuis le dĂ©pĂŽt Git** - DĂ©pĂŽt principal : https://git.peis.fr/VisualPCI/homelab-config - Clone local : `~/homelab-config` (WSL) - **JAMAIS** modifier les fichiers locaux sur `C:\Users\theo\.vibe\Proxmox\inventair\` 2. **Avant TOUTE action** : ```bash cd ~/homelab-config GIT_SSL_NO_VERIFY=true git pull origin main ``` 3. **AprĂšs TOUTE modification** : ```bash git add . git commit -m "description claire de la modification" GIT_SSL_NO_VERIFY=true git push origin main ``` 4. **Authentification Git** : - URL : `https://Windsurf:3N14E7GWVSgi3K@git.peis.fr/VisualPCI/homelab-config.git` - Utilisateur : Windsurf - Mot de passe / token : 3N14E7GWVSgi3K - Commit author : `Windsurf ` --- ## 📁 Structure du dĂ©pĂŽt ``` homelab-config/ ├── AGENTS.md ← Ce fichier ├── INSTRUCTIONS.md ← Instructions gĂ©nĂ©rales ├── homelab-inventaire.md ← Inventaire principal ├── status-monitor/ ← Service de monitoring │ ├── app.py ← Code principal (corrigĂ©) │ ├── app_v1.py ← Backup ancienne version │ ├── app_v2.py ← Backup ancienne version │ ├── deploy.sh ← Script de dĂ©ploiement │ └── dynamic_traefik.yml ← Configuration Traefik ├── traefik-config/ ← Configurations Traefik ├── projet-authent/ ← DĂ©ploiement Authentik (CT203) │ ├── docker-compose.yml ← Stack Authentik │ ├── .env ← Variables d'environnement │ ├── authentik-secrets.md ← Secrets │ └── readme.md ← RĂ©sumĂ© du dĂ©ploiement └── procedure-*.md ← Documentations ``` --- ## 🚀 DĂ©ploiement Status Monitor (CT201) ### Serveur cible - **IP** : 192.168.0.201 - **Service** : `status-monitor` (systemd) - **Dossier** : `/opt/status-monitor/` - **URL** : https://status.peis.fr ### Workflow de dĂ©ploiement **⚠ Flux obligatoire : IDE (Windows) -> WSL -> CT200/CT100 (bastion 192.168.0.100) -> CT201 (192.168.0.201)** ``` IDE (C:\Users\theo\homelab_ia\homelab-config) └── copy ───> WSL (~/homelab-config) └── scp -J root@192.168.0.100 ───> CT201 (192.168.0.201) ``` #### 1. Modifier le code dans l'IDE Modifier `status-monitor/app.py` dans l'IDE Windows. #### 2. Synchroniser IDE -> WSL ```bash cp /mnt/c/Users/theo/homelab_ia/homelab-config/status-monitor/app.py ~/homelab-config/status-monitor/app.py ``` #### 3. Commiter et pusher ```bash cd ~/homelab-config GIT_SSL_NO_VERIFY=true git add status-monitor/ GIT_SSL_NO_VERIFY=true git commit -m "Fix: description de la correction" GIT_SSL_NO_VERIFY=true git push origin main ``` #### 4. DĂ©ployer sur CT201 **Option A - DĂ©ploiement automatique (recommandĂ©) :** ```bash wsl bash ~/homelab-config/status-monitor/deploy.sh ``` Ce script synchronise automatiquement l'IDE -> WSL puis dĂ©ploie via CT200/CT100. **Option B - DĂ©ploiement manuel :** ```bash # WSL -> CT201 (rebond via CT200/CT100 bastion) scp -J root@192.168.0.100 -i ~/.ssh/id_ed25519 ~/homelab-config/status-monitor/app.py root@192.168.0.201:/tmp/app.py # Installation et redĂ©marrage sur CT201 ssh -J root@192.168.0.100 -i ~/.ssh/id_ed25519 root@192.168.0.201 'mv /tmp/app.py /opt/status-monitor/app.py && systemctl restart status-monitor' ``` #### 5. VĂ©rifier le dĂ©ploiement ```bash # VĂ©rifier l'API curl -k -s https://status.peis.fr/api/status | python3 -m json.tool # Ou via navigateur https://status.peis.fr ``` --- ## 🐞 Corrections courantes ### ProblĂšme : Cache non rafraĂźchi **SymptĂŽme** : La page status affiche des donnĂ©es anciennes **Cause** : `status_cache` n'Ă©tait pas rafraĂźchi aprĂšs le premier chargement **Solution appliquĂ©e** : ```python # AVANT (bug) : if not status_cache: check_all() # APRÈS (corrigĂ©) : check_all() # Toujours rafraĂźchir Ă  chaque appel ``` **Fichier** : `status-monitor/app.py` (ligne 372) --- ## 📋 Commandes utiles ### Git ```bash # État cd ~/homelab-config && git status # Pull cd ~/homelab-config && git pull # Commit cd ~/homelab-config && git add . && git commit -m "message" && git push # Voir l'historique cd ~/homelab-config && git log --oneline --graph ``` ### SSH CT201 (via rebond CT200) ```bash # Se connecter (CT200 est le bastion) ssh -J root@192.168.0.100 root@192.168.0.201 # Voir les logs du service ssh -J root@192.168.0.100 root@192.168.0.201 "journalctl -u status-monitor -f" # État du service ssh -J root@192.168.0.100 root@192.168.0.201 "systemctl status status-monitor" # RedĂ©marrer ssh -J root@192.168.0.100 root@192.168.0.201 "systemctl restart status-monitor" ``` ### SSH CT200 (direct) ```bash # Se connecter directement ssh -i ~/.ssh/id_ed25519 root@192.168.0.100 # Copier des fichiers vers CT200 scp -i ~/.ssh/id_ed25519 fichier root@192.168.0.100:/destination/ # Copier des fichiers de CT200 vers local scp -i ~/.ssh/id_ed25519 root@192.168.0.100:/source/fichier ./ ``` ### Gitea - **URL** : https://git.peis.fr - **Compte** : VisualPCI - **DĂ©pĂŽt** : https://git.peis.fr/VisualPCI/homelab-config ### Workflow complet utilisĂ© pour la correction du 20/07/2026 **ProblĂšme** : SyntaxError: Unexpected identifier 'card' (at index.html:101:35) **Cause** : Dans `status-monitor/app.py`, les strings JavaScript utilisaient `class=\"` qui gĂ©nĂ©rait du code JS invalide. **Workflow appliquĂ©** : ```bash # 1. Cloner depuis WSL (Ubuntu) cd ~/homelab-config git clone https://VisualPCI:3N14E7GWVSgi3K@git.peis.fr/VisualPCI/homelab-config.git # 2. RĂ©cupĂ©rer le fichier buggĂ© depuis CT201 (via CT200) ssh -J root@192.168.0.100 root@192.168.0.201 cat /opt/status-monitor/app.py > status-monitor/app_from_ct201.py # 3. Corriger le bug avec Python (remplacer \" par ') python3 -c " with open('status-monitor/app.py', 'r') as f: content = f.read() content = content.replace('\\\"', \"'\") with open('status-monitor/app.py', 'w') as f: f.write(content) " # 4. VĂ©rifier la syntaxe Python python3 -m py_compile status-monitor/app.py # 5. Commiter avec GIT_SSL_NO_VERIFY GIT_SSL_NO_VERIFY=true git add status-monitor/app.py GIT_SSL_NO_VERIFY=true git commit -m "Fix(status-monitor): Correction des guillemets dans le JavaScript - Resout SyntaxError loading" # 6. Pull avec rebase (conflit dĂ©tectĂ©) GIT_SSL_NO_VERIFY=true git pull --rebase origin main # 7. Pousser vers git.peis.fr GIT_SSL_NO_VERIFY=true git push origin main # 8. Deployer sur CT201 (via CT200 comme bastion) # MĂ©thode 1 : Copier via CT200 cat status-monitor/app.py | ssh -i ~/.ssh/id_ed25519 root@192.168.0.100 'cat > /tmp/app_new.py' ssh -i ~/.ssh/id_ed25519 root@192.168.0.100 'scp /tmp/app_new.py root@192.168.0.201:/opt/status-monitor/app.py && chmod +x /opt/status-monitor/app.py' ssh -i ~/.ssh/id_ed25519 root@192.168.0.100 'ssh root@192.168.0.201 systemctl restart status-monitor' # MĂ©thode 2 : Direct avec -J (bastion) scp -J root@192.168.0.100 -i ~/.ssh/id_ed25519 status-monitor/app.py root@192.168.0.201:/opt/status-monitor/app.py ssh -J root@192.168.0.100 root@192.168.0.201 'chmod +x /opt/status-monitor/app.py && systemctl restart status-monitor' ``` **RĂ©sultat** : - Commit `685060c` poussĂ© vers git.peis.fr - Fichier corrigĂ© dĂ©ployĂ© sur CT201 - Service redĂ©marrĂ© avec succĂšs **Leçons apprises** : - Toujours utiliser `-J` pour le rebond SSH vers CT201 - `GIT_SSL_NO_VERIFY=true` est nĂ©cessaire pour contourner les problĂšmes de certificat - Utiliser `python3` pour les scripts de correction complexes - Tester la syntaxe Python avant de deployer --- ## 🚹 Erreurs Ă  Ă©viter - ❌ Modifier directement les fichiers sur CT201 sans passer par Git - ❌ Oublier de faire `git pull` avant de modifier un fichier - ❌ Oublier de commiter et pusher aprĂšs une modification - ❌ Travailler depuis plusieurs emplacements diffĂ©rents - ❌ Modifier les fichiers dans `C:\Users\theo\.vibe\Proxmox\inventair\` --- ## ✅ Checklist avant dĂ©ploiement - [ ] `git pull` exĂ©cutĂ© - [ ] Modifications testĂ©es localement - [ ] `git add .` exĂ©cutĂ© - [ ] `git commit -m "..."` exĂ©cutĂ© - [ ] `git push origin main` exĂ©cutĂ© - [ ] DĂ©ploiement vĂ©rifiĂ© sur https://status.peis.fr --- ## 📊 Historique des modifications | Date | Commit | Description | |------|--------|-------------| | 2026-07-20 | `685060c` | Fix(status-monitor): Correction des guillemets dans le JavaScript - Resout SyntaxError loading | | 2026-07-19 | `6b77f49` | Fix: Force cache refresh on /api/status endpoint | | 2026-07-19 | `3ed1d96` | Add: deploy.sh script for DevOps workflow | | 2026-07-19 | `da6b794` | Ajout: INSTRUCTIONS.md pour workflow Git | --- *DerniĂšre mise Ă  jour : 2026-07-20* *DerniĂšre mise Ă  jour : 2026-07-19* *Pour : Mistral Vibe et agents homelab*