Fleet Management¶
Orchestrate commands across multiple VMs with parallel execution and intelligent routing.
Overview¶
Fleet commands enable distributed operations across VM fleets with pattern matching, parallel execution, and comprehensive error handling.
Available Commands¶
Distributed Operations¶
- Fleet Overview - Fleet management concepts and patterns
- azlin batch command - Execute commands on multiple VMs
- azlin batch sync - Sync files to VM fleets
- azlin w - Distributed
wcommand - azlin ps - Distributed
ps auxcommand
Quick Start Examples¶
Execute on All VMs¶
# Run command on every VM
azlin batch exec "*" "docker ps"
# Check disk space across fleet
azlin batch exec "*" "df -h"
# Update all VMs
azlin batch exec "*" "sudo apt update && sudo apt upgrade -y"
Pattern Matching¶
# Target specific VM groups
azlin batch exec "api-*" "systemctl restart nginx"
azlin batch exec "db-*" "docker logs postgres"
azlin batch exec "test-*" "rm -rf /tmp/*"
# Multiple patterns
azlin batch exec "web-*,api-*" "git pull origin main"
Specific VM Lists¶
# Comma-separated VM names
azlin batch exec "vm1,vm2,vm3" "uptime"
# Tag-based selection
azlin batch exec --tag env=prod "systemctl status myapp"
Monitoring Fleet¶
# Who's logged in across fleet
azlin w
# All running processes
azlin ps
# Filter by pattern
azlin w --filter "api-*"
azlin ps --filter "db-*"
Key Features¶
Parallel Execution¶
Execute commands simultaneously across VMs:
# Parallel updates
azlin batch exec "*" "git pull" --parallel 10
# Sequential for safety
azlin batch exec "*" "systemctl restart app" --sequential
Error Handling¶
Continue execution even if some VMs fail:
# Continue on errors
azlin batch exec "*" "risky-command" --continue-on-error
# Stop on first failure
azlin batch exec "*" "critical-command" --stop-on-error
Output Aggregation¶
Collect and format results:
# Show all output
azlin batch exec "api-*" "docker ps" --verbose
# Summary only
azlin batch exec "*" "uptime" --summary
# Save to file
azlin batch exec "*" "systemctl status" > fleet-status.txt
File Distribution¶
Sync files to multiple VMs:
# Sync to all VMs
azlin batch sync "*" ~/myproject
# Sync to specific pattern
azlin batch sync "web-*" ~/frontend --delete
# Dry-run first
azlin batch sync "*" ~/config --dry-run
Common Workflows¶
Deploy Application Update¶
# 1. Sync code to all app servers
azlin batch sync "app-*" ~/myapp
# 2. Restart services
azlin batch exec "app-*" "systemctl restart myapp"
# 3. Verify status
azlin batch exec "app-*" "systemctl status myapp"
Fleet Health Check¶
# Check system resources
azlin batch exec "*" "df -h && free -h && uptime"
# Check application status
azlin batch exec "*" "systemctl status myapp"
# Check docker containers
azlin batch exec "*" "docker ps && docker stats --no-stream"
Configuration Management¶
# Update configuration
azlin batch sync "*" ~/config/nginx.conf /etc/nginx/
# Reload services
azlin batch exec "*" "sudo systemctl reload nginx"
# Verify configuration
azlin batch exec "*" "nginx -t"
Log Collection¶
# Collect application logs
azlin batch exec "*" "tail -n 100 /var/log/myapp.log" > all-logs.txt
# Search for errors
azlin batch exec "*" "grep ERROR /var/log/myapp.log"
# Download logs
for vm in $(azlin list --name-only); do
azlin connect $vm --command "cat /var/log/myapp.log" > logs/${vm}.log
done
Pattern Matching Reference¶
Wildcard Patterns¶
# All VMs starting with "api-"
azlin batch exec "api-*" "command"
# All VMs ending with "-prod"
azlin batch exec "*-prod" "command"
# All VMs containing "test"
azlin batch exec "*test*" "command"
Multiple Patterns¶
# Match multiple patterns (OR)
azlin batch exec "web-*,api-*,db-*" "command"
# Exclude pattern (requires explicit list)
# List all VMs, then filter manually
azlin list --name-only | grep -v "test-" | xargs -I {} azlin connect {} --command "..."
Tag-Based Selection¶
# Select by tag
azlin batch exec "*" "command" --tag env=prod
# Multiple tags
azlin batch exec "*" "command" --tag env=prod --tag app=web
Performance Tuning¶
Parallelism¶
# Default: 5 parallel executions
azlin batch exec "*" "command"
# More parallel (faster, more load)
azlin batch exec "*" "command" --parallel 20
# Sequential (slower, more reliable)
azlin batch exec "*" "command" --sequential
Timeout Control¶
# Set timeout per VM
azlin batch exec "*" "long-command" --timeout 300
# No timeout (wait forever)
azlin batch exec "*" "command" --no-timeout
Retry Logic¶
# Retry failed commands
azlin batch exec "*" "flaky-command" --retry 3
# Retry delay
azlin batch exec "*" "command" --retry 3 --retry-delay 5
Best Practices¶
1. Test with Dry-Run¶
# Always test sync operations
azlin batch sync "*" ~/important-data --dry-run
azlin batch sync "*" ~/important-data
2. Use Patterns Wisely¶
# Good: Specific patterns
azlin batch exec "api-prod-*" "restart-command"
# Risky: Too broad
azlin batch exec "*" "dangerous-command"
3. Monitor Output¶
# Use verbose for important operations
azlin batch exec "*" "critical-command" --verbose
# Save output for auditing
azlin batch exec "*" "command" | tee operation.log
4. Handle Failures¶
# Critical operations: Stop on error
azlin batch exec "*" "database-migration" --stop-on-error
# Best-effort operations: Continue on error
azlin batch exec "*" "optional-update" --continue-on-error
Fleet Monitoring Commands¶
System Status¶
# Logged-in users
azlin w
# All processes
azlin ps
# System resources
azlin batch exec "*" "top -bn1 | head -20"
Application Status¶
# Service status
azlin batch exec "*" "systemctl status myapp"
# Docker containers
azlin batch exec "*" "docker ps"
# Application health
azlin batch exec "*" "curl -sf http://localhost:8080/health"
Logs and Diagnostics¶
# Recent logs
azlin batch exec "*" "journalctl -n 50"
# Error logs
azlin batch exec "*" "grep ERROR /var/log/myapp.log | tail -20"
# Disk usage
azlin batch exec "*" "df -h"
Error Handling¶
Common Issues¶
Connection failures:
Command failures:
Timeout issues:
Related Commands¶
- azlin batch command - Batch command execution
- azlin batch sync - Batch file synchronization
- azlin w - Distributed
wcommand - azlin ps - Distributed
ps auxcommand - azlin compose - Multi-VM infrastructure