Système permettant d'exécuter des playbooks Ansible sur des hôtes distants sans connexion SSH entrante. Les agents clients initient eux-mêmes la connexion vers un serveur central (modèle Salt Minion, connexions inversées).
cd ansible_server
docker compose up --build -d
curl http://localhost:7770/healthcd ansible_minion
docker compose up --build -d
docker logs secagent-minion-01 # Vérifier la connexionansible-secagent/
├── ansible_server/ # Déploiement serveur (Phase 2)
│ ├── docker-compose.yml - nats, relay-api, caddy
│ └── .env - Variables d'environnement
│
├── ansible_minion/ # Déploiement agents (Phase 1)
│ └── docker-compose.yml - secagent-minion-01/02/03
│
├── agent/ # Code agent client
│ ├── secagent_agent.py - Point d'entrée principal
│ ├── async_registry.py - Registre des tâches async
│ ├── facts_collector.py - Collecte system facts
│ ├── agent_entrypoint.py - Wrapper d'initialisation
│ └── Dockerfile.agent - Image Docker agent
│
├── server/ # Code serveur FastAPI
│ ├── api/
│ │ ├── main.py - Application FastAPI
│ │ ├── routes_register.py - Enrollment + JWT auth
│ │ ├── ws_handler.py - Gestionnaire WebSocket
│ │ ├── routes_exec.py - Task exec/upload/fetch
│ │ └── routes_inventory.py - Inventaire dynamique
│ ├── db/
│ │ └── agent_store.py - Modèles + ORM SQLite
│ ├── broker/
│ │ └── nats_client.py - Client NATS JetStream
│ ├── Dockerfile - Image Docker server
│ └── requirements.txt - Dépendances Python
│
├── ansible_plugins/ # Plugins Ansible
│ ├── connection_plugins/
│ │ └── secagent.py - ConnectionBase (remplace SSH)
│ └── inventory_plugins/
│ └── secagent_inventory.py - InventoryModule dynamique
│
├── tests/ # Tests & qualification
│ ├── unit/ - Tests unitaires
│ ├── integration/ - Tests intégration
│ ├── e2e_multiagent_test.yml - Playbook E2E
│ └── inventory_relay.ini - Inventaire test
│
├── ARCHITECTURE.md # Spécifications techniques v1.1
├── DEPLOYMENT.md # Guide de déploiement
├── HLD.md # Design haut niveau
└── CLAUDE.md # Instructions Claude Code
| Document | Contenu |
|---|---|
| ARCHITECTURE.md | Spécifications techniques détaillées (protocoles, formats, sécurité) |
| DEPLOYMENT.md | Guide complet de déploiement (server + minions) |
| HLD.md | Architecture haut niveau et flux de messages |
| CLAUDE.md | Instructions projet pour Claude Code |
┌─────────┐ ┌──────────┐ ┌─────────┐ ┌──────────┐
│ Ansible │ │ Relay │ │ NATS │ │ Relay │
│ Control │───────▶│ Server │───────▶│ Message │◀──────▶│ Agent │
│ Machine │ │ (FastAPI)│ │ Broker │ │ (Minion) │
└─────────┘ └──────────┘ └─────────┘ └──────────┘
│ │
└──────────── WebSocket ───────────────┘
(Bidirectionnel)
- Playbook Ansible → Plugin connection_relay (HTTP/REST)
- Server relay-api → Enqueue task dans NATS stream
- Agent WebSocket → Reçoit tâche via canal persistant
- Agent subprocess → Exécute la commande Ansible
- Agent → Server → Upload résultat via HTTP
- Server → NATS → Persiste résultat
- Plugin reads → Récupère résultat via /api/exec/{task_id}
| Aspect | SSH | Ansible-SecAgent |
|---|---|---|
| Connexion | Entrante (serveur initie) | Sortante (agent initie) |
| Firewall | SSH port ouvert | Sortante HTTPS uniquement |
| Credentials | SSH keys distribuées | JWT + RSA-4096 |
| Scaling | N connexions SSH | 1 WebSocket par agent |
| NAT Friendly | Difficile | Natif (agents derrière NAT) |
- Agent : Python 3.11+, asyncio, websockets, RSA-4096
- Serveur : Python 3.11+, FastAPI, NATS JetStream, SQLite/PostgreSQL
- Plugins Ansible : Python, ConnectionBase, InventoryModule
- Transport : WSS (obligatoire TLS), HTTP/REST
- Authentification : JWT HMAC-SHA256, RSA challenge-response
- Orchestration : Docker Compose (qualif), Kubernetes Helm (prod)
✅ Validé par security review (0 findings CRITICAL/HAUT)
- JWT signé HMAC-SHA256
- RSA-4096 key exchange à l'enrollment
- Challenge-response pour token refresh
- JTI blacklist (revocation)
- TLS obligatoire pour production
- Rôles RBAC (agent/plugin/admin)
- ✅ Phase 0 : Backlog + architecture (41 tâches)
- ✅ Phase 1 : secagent-minion + tests
- ✅ Phase 2 : secagent-server + NATS JetStream
- ✅ Phase 3 : Plugins Ansible + E2E tests
- ⏳ Phase 4 : Production Kubernetes (après validation)
- Architecture : Voir
ARCHITECTURE.mdetHLD.md - Déploiement : Voir
DEPLOYMENT.md - Développement : Voir
CLAUDE.mdpour les conventions - Tests :
pytest tests/ -v
MVP Status : ✅ COMPLETE — Prêt pour qualification et production Kubernetes