How blalabs/ansible-worker works
ansible-worker receives playbook requests through either MQTT or HTTP, validates and queues them, then executes one task at a time with ansible-playbook. Execution updates task state and parses Ansible output into progress counters and terminal results. The orchestrator routes those updates back through the selected transport. Configuration supports shared MQTT delivery, authenticated/TLS HTTP or MQTT, optional Git pulls, bounded queues, timeouts, and graceful cancellation. Some wiring is inferred only from documented interfaces and sampled excerpts.
Main entry points: main.rs Worker Orchestrator · executor.rs Task Executor · mqtt.rs MQTT Receiver · http.rs HTTP Receiver
Components 17
Control Plane
- Config Loader
src/config.rs - Worker Orchestrator
src/main.rs
Task Ingress
- MQTT Receiver
src/transport/mqtt.rs - HTTP Receiver
src/transport/http.rs - Task Request
src/models.rs - Bounded Task Queue
src/task_queue.rs
Execution
- Task Executor
src/executor.rs - Path Validation
src/executor.rs - Output Parser
src/executor.rs
Status Reporting
- Task Status
src/models.rs - MQTT Publisher
src/transport/mqtt.rs - HTTP Publisher
src/transport/http.rs
External Dependencies
- ansible-playbook
- MQTT Broker
- HTTP Task API
- Git Repository
Other components
- Operator
Connections 24
- Operator → Worker Orchestrator: starts worker
- Worker Orchestrator → Config Loader: loads config
- Worker Orchestrator → MQTT Receiver: starts transport
- Worker Orchestrator → HTTP Receiver: starts transport
- Worker Orchestrator → Bounded Task Queue: creates queue
- Worker Orchestrator → Task Executor: starts executor
- MQTT Broker → MQTT Receiver: delivers tasks
- HTTP Task API → HTTP Receiver: serves tasks
- MQTT Receiver → Task Request: parses payload
- HTTP Receiver → Task Request: parses JSON
- MQTT Receiver → Bounded Task Queue: enqueues tasks
- HTTP Receiver → Bounded Task Queue: enqueues tasks
- Bounded Task Queue → Task Executor: provides tasks
- Task Executor → Path Validation: validates paths
- Task Executor → Git Repository: pulls repository
- Task Executor → ansible-playbook: runs playbook
- ansible-playbook → Output Parser: writes stdout
- Output Parser → Task Status: updates counts
- Task Executor → Task Status: sets state
- Task Executor → Worker Orchestrator: sends status
- Worker Orchestrator → MQTT Publisher: dispatches updates
- Worker Orchestrator → HTTP Publisher: dispatches updates
- MQTT Publisher → MQTT Broker: publishes status
- HTTP Publisher → HTTP Task API: posts status