Federated Learning Infrastructure | Automated DevOps
Deploy and manage a distributed federated learning system across multiple Linux machines with a single command.
Quick Start β’ Architecture β’ Playbooks β’ Configuration β’ Troubleshooting
IPD (Intelligent Processing & Distribution) is a federated learning system designed for distributed ML training across a controllerβedge architecture. This repository contains all the Ansible automation needed to:
- π§ Set up systems with Python 3.12 and Go 1.24
- π¦ Deploy the complete IPD stack
βΆοΈ Start/Stop services across all nodes- π Update code and restart automatically
- π Monitor service health and status
βββββββββββββββββββββββ
β Controller β
β βββββββββββββββ β
β β Go Binary β β
β β (Orchestrator) β
β βββββββββββββββ β
β βββββββββββββββ β
β β API Server β β
β β (Python) β β
β βββββββββββββββ β
ββββββββββββ¬βββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Edge 1 β β Edge 2 β β Edge N β
β βββββββββββ β β βββββββββββ β β βββββββββββ β
β βGo Binaryβ β β βGo Binaryβ β β βGo Binaryβ β
β βββββββββββ β β βββββββββββ β β βββββββββββ β
β βββββββββββ β β βββββββββββ β β βββββββββββ β
β βML Train β β β βML Train β β β βML Train β β
β β(Python) β β β β(Python) β β β β(Python) β β
β βββββββββββ β β βββββββββββ β β βββββββββββ β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
| Node | Components | Responsibilities |
|---|---|---|
| Controller | Go orchestrator + Python API | Coordinates FL rounds, distributes tasks, aggregates models |
| Edge | Go node + Python ML trainer | Performs local training, sends model updates |
| Component | Technology | Version |
|---|---|---|
| Orchestration | Ansible | Latest |
| Core Logic | Go | 1.24.0 |
| ML Training | Python + PyTorch/TensorFlow | 3.12 |
| Computer Vision | Ultralytics YOLO | 8.3.x |
| Communication | WebRTC + WebSockets | - |
| Service Mgmt | systemd | - |
| Target OS | Ubuntu | 22.04+ |
ipd-ansible/
βββ ansible.cfg # Ansible configuration
βββ inventory/
β βββ hosts.ini # Target machines
βββ playbooks/
β βββ setup.yml # Install Python & Go
β βββ deploy.yml # Deploy full stack
β βββ start.yml # Start all services
β βββ stop.yml # Stop all services
β βββ status.yml # Check health
β βββ update.yml # Hot update code
βββ group_vars/
β βββ all.yml # Shared variables
β βββ controllers.yml # Controller config
β βββ edges.yml # Edge config
βββ requirements/
β βββ edge-requirements.txt # ML dependencies
βββ templates/
β βββ controller.service.j2 # systemd templates
β βββ api_server.service.j2
β βββ edge.service.j2
β βββ edge_start.sh.j2
β βββ ml_trainer.service.j2
βββ project/ # IPD source code (Go + Python)- Control machine: Ansible 2.9+, SSH access to all nodes
- Target nodes: Ubuntu 22.04+, sudo privileges
- Network: SSH connectivity between all nodes
Edit inventory/hosts.ini with your machines:
[controllers]
controller1 ansible_host=192.168.1.100
[edges]
edge1 ansible_host=192.168.1.101
edge2 ansible_host=192.168.1.102
edge3 ansible_host=192.168.1.103
[all:vars]
ansible_user=your_username
ansible_become=true
ansible_python_interpreter=/usr/bin/python3Install Python 3.12 and Go 1.24 on all nodes:
ansible-playbook playbooks/setup.ymlDeploy the full IPD stack:
ansible-playbook playbooks/deploy.ymlβ±οΈ Note: First deployment on edges can take 15-30 minutes due to ML dependencies (~3GB of packages including TensorFlow, PyTorch, and Ultralytics).
ansible-playbook playbooks/start.ymlansible-playbook playbooks/status.yml| Playbook | Description | Example |
|---|---|---|
setup.yml |
Install Python 3.12, Go 1.24, create users | ansible-playbook playbooks/setup.yml |
deploy.yml |
Sync code, build binaries, install deps, create services | ansible-playbook playbooks/deploy.yml |
start.yml |
Start and enable all systemd services | ansible-playbook playbooks/start.yml |
stop.yml |
Stop all services | ansible-playbook playbooks/stop.yml |
status.yml |
Check service health, ports, disk space | ansible-playbook playbooks/status.yml |
update.yml |
Hot update: sync code, rebuild, restart | ansible-playbook playbooks/update.yml |
# Only edges
ansible-playbook playbooks/deploy.yml --limit edges
# Single host
ansible-playbook playbooks/status.yml --limit edge1
# Only controllers
ansible-playbook playbooks/start.yml --limit controllersansible-playbook playbooks/deploy.yml --checkapp_base_dir: /opt/ipd # Installation directory
go_version: "1.24.0" # Go version to install
python_version: "3.12" # Python version
venv_dir: /opt/ipd/venv # Python virtual environmentnode_role: controller
services:
- name: controller
type: go
binary: controller
build_path: ./main/
- name: api_server
type: python
script: main/api_server.py
port: 8000node_role: edge
services:
- name: ml_trainer
type: python
script: edge/process_images.py
port: 8765
- name: edge
type: go
binary: edge_node
build_path: ./edge/
pip_install_timeout: 1800 # 30 min for ML packages| Service | Type | Port | Description |
|---|---|---|---|
controller |
Go | - | Main orchestration logic |
api_server |
Python | 8000 | REST API for control/monitoring |
| Service | Type | Port | Description |
|---|---|---|---|
edge |
Go | - | Edge node communication |
ml_trainer |
Python | 8765 | ML training + inference |
# View logs on a specific node
ssh edge1 'journalctl -u ml_trainer -f'
# Restart a service manually
ssh edge1 'sudo systemctl restart edge'
# Check service status
ssh edge1 'sudo systemctl status ml_trainer'β SSH Connection Failed
# Test connectivity
ansible all -m ping
# Verbose output
ansible-playbook playbooks/setup.yml -vvvEnsure:
- SSH keys are properly configured
ansible_userhas sudo access- Firewall allows SSH (port 22)
β Pip Install Timeout
ML dependencies are large (~3GB). Increase timeout in group_vars/edges.yml:
pip_install_timeout: 3600 # 1 hourOr use a faster mirror:
pip_extra_args: "--timeout 3600 -i https://pypi.tuna.tsinghua.edu.cn/simple"β Go Build Failed
# SSH to the node and check manually
ssh edge1
cd /opt/ipd/project
source /etc/profile.d/go.sh
go mod tidy
go build -v ./...β Service Won't Start
# Check logs
ssh edge1 'journalctl -u edge -n 50 --no-pager'
# Verify binary exists
ssh edge1 'ls -la /opt/ipd/project/edge_node'
# Test running manually
ssh edge1 'cd /opt/ipd/project && ./edge_node'# Check all nodes
ansible all -m shell -a "hostname && uptime"
# Check disk space
ansible edges -m shell -a "df -h /"
# Check Python version
ansible all -m shell -a "python3 --version"
# Check Go version
ansible all -m shell -a "source /etc/profile.d/go.sh && go version"To add more edge nodes:
-
Add to inventory:
[edges] edge1 ansible_host=192.168.1.101 edge2 ansible_host=192.168.1.102 edge_new ansible_host=192.168.1.105 # New node
-
Setup and deploy:
ansible-playbook playbooks/setup.yml --limit edge_new ansible-playbook playbooks/deploy.yml --limit edge_new ansible-playbook playbooks/start.yml --limit edge_new
| Description | |
|---|---|
| System Python | Do NOT remove the system Python installation |
| Initial Deploy | First edge deployment can take 15-30 minutes (ML deps) |
| SSH Access | All nodes must have SSH key authentication configured |
| Disk Space | Edges need ~5GB free for ML packages + venv |
| Project Structure | Keep go.mod at project root |
- π¬ Research: Federated learning experiments
- π Production: Edge computing deployments
- π Academic: Distributed ML training labs
- π§ͺ Testing: Multi-node orchestration testing
This project is for internal use.
Built with β€οΈ using Ansible
Last updated: 2026-01-20