How ansible/eda-server works
Project type and purpose
• This is a full-stack, event-driven orchestration platform (“EDA Controller”) built on Django.
• It exposes a REST/WS API, processes activations (rulebooks) via pluggable container engines (Podman/Kubernetes), manages tasks via RQ/async queues (Redis), persists state in PostgreSQL, and collects analytics.
File structure
• src/aap_eda/api: Django REST API layer (views, serializers, authentication, filters).
• src/aap_eda/wsapi: WebSocket consumers and routing.
• src/aap_eda/core: Core Django app—models, migrations, management commands, URL routing.
• src/aap_eda/services: Business-logic services (activation manager, status manager, container-engine factory).
• src/aap_eda/tasks: Background tasks/orchestrator that enqueue and schedule work.
• src/aap_eda/analytics: Collectors for usage/metrics.
• src/aap_eda/conf & settings: Configuration registry and Django settings modules.
• scripts/ and tools/: Dev and deployment scripts (Docker, k8s manifests).
• Third-party integrations: AWX (Ansible Tower), external event streams (Kafka, RabbitMQ, pg_notify).
Key architecture insights from README/docs
• Deployment guide references PostgreSQL, Redis, nginx, TLS, Kubernetes deployments for API, workers, scheduler, UI.
• CI pipeline runs tests and builds container images.
Main components & interactions
a. API Layer
• Django REST Framework (src/aap_eda/api) behind NGINX (ingress).
• WebSocket endpoint (src/aap_eda/wsapi) for real-time event/status updates.
b. Persistence & Messaging
• PostgreSQL: relational data store (core models, activations, analytics).
• Redis: RQ queue for tasks (activation queue, analytics jobs, scheduler).
• Event Streams: external brokers or pg_notify for inbound events.
c. Background Workers
• Scheduler process (management command “scheduler”) dispatches activation requests to Redis.
• RQ workers (rqworker cmd) pick up tasks, call services/orchestrator.
• Orchestrator & Activation Manager: choose container engine (Podman/K8s), launch rulebook runs.
d. Container Engines
• Podman or Kubernetes abstractions (src/aap_eda/services/activation/engine).
• Each activation is run in its own container/pod, logs captured via Tee logger into DB.
e. Analytics
• Analytics collectors run periodically or per activation to gather metrics into the data warehouse.
f. External Integrations
• AWX token retrieval for credentials.
• Event streams authenticated via HMAC/JWT/OAuth2.
• SMS gateway for notifications.
Architectural patterns & principles
• Layered Architecture: Presentation (API/WS), Application (views/serializers/tasks), Domain (services/core), Infrastructure (DB, Redis, container engines).
• Queuing & Pub-Sub: Redis as work queue; pluggable brokers for events.
• Polyglot Container Engines: Factory pattern selects Podman or K8s at runtime.
• Micro-Deployment: Multiple k8s Deployments (api, default-worker, activation-worker, scheduler, UI).
• Twelve-Factor App: Config via env vars, external backing services, stateless containers.