This guide provides comprehensive instructions for managing deployments of the Auto Drive system using Ansible scripts. The deployment infrastructure supports multiple environments and components across different networks (Mainnet and Taurus) with various configurations.
- Architecture Overview
- Target Machine Tags
- Prerequisites
- Environment Setup
- Deployment Procedures
- Service Components
- Configuration Management
- Troubleshooting
- Best Practices
The Auto Drive system consists of two main components:
- Auto Drive Services: Main storage and data access layer services
auto_drive_mainnet_private: Private mainnet deployment for internal servicesauto_drive_mainnet_public: Public mainnet deployment for external accessauto_drive_taurus_private: Private taurus testnet deploymentauto_drive_taurus_public: Public taurus testnet deployment
auto_drive_mainnet_staging: Staging environment for mainnet testingauto_drive_taurus_staging: Staging environment for taurus testing
- Ansible: Version 2.9 or later
- Docker: Installed on target machines
- Docker Compose: Version 2.0 or later
- Infisical CLI: For secrets management
- SSH Access: To all target machines
# Install Ansible
pip install ansible
# Install required Ansible collections
ansible-galaxy collection install ansible.posix
ansible-galaxy collection install community.generalAll target machines must have:
- Docker and Docker Compose installed
- SSH access configured
- Infisical CLI installed (automatically handled by setup playbook)
- Deployment directories created:
~/deploy/auto-drive/~/env-archives/
Create an environment.yaml file in the ansible/ directory:
# Infisical Configuration
infisical_client_id: "your-client-id"
infisical_token: "your-client-secret"
infisical_project_id: "your-project-id"
# Additional environment-specific variablesThe hosts.ini file is already created in the ansible/ directory with all target machine tags. Update it with your actual host information:
- Uncomment and configure hosts as needed for your environment
- Replace placeholder IP addresses with actual values
- Adjust hostnames to match your infrastructure
Example configuration:
[auto_drive_mainnet_private]
user@mainnet-private-1
user@mainnet-private-2
[auto_drive_mainnet_public]
user@mainnet-public-1
user@mainnet-public-2The format is user@hostname or user@ip-address for each host entry.
The inventory includes:
- Individual target machine groups for each service
- Logical groupings (production, staging, mainnet, taurus)
- Environment-specific variables for each group
- Common variables for all hosts
The ansible.cfg file is configured to use the hosts.ini inventory and includes optimized settings for deployment operations.
First, set up Infisical on all target machines:
# Setup Infisical on specific target machines
ansible-playbook setup-infisical.yml -e "target_machines=auto_drive_mainnet_private"
# Setup Infisical on all machines
ansible-playbook setup-infisical.yml -e "target_machines=all"Deploy to specific environments:
# Deploy to mainnet private
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_private" \
-e "image_tag=latest"
# Deploy to mainnet public
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_public" \
-e "image_tag=v1.2.3"
# Deploy to taurus private
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_taurus_private" \
-e "image_tag=latest"
# Deploy to taurus public
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_taurus_public" \
-e "image_tag=v1.2.3"
# Deploy to staging environments
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_staging" \
-e "image_tag=staging-latest"
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_taurus_staging" \
-e "image_tag=staging-latest"Deploy to multiple environments simultaneously:
# Deploy to all staging environments
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_staging,auto_drive_taurus_staging" \
-e "image_tag=staging-latest"
# Deploy to all production environments
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_private,auto_drive_mainnet_public,auto_drive_taurus_private,auto_drive_taurus_public" \
-e "image_tag=v1.2.3"Use the logical groupings defined in the inventory:
# Deploy to all auto drive production environments
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_production" \
-e "image_tag=v1.2.3"
# Deploy to all staging environments
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_staging" \
-e "image_tag=staging-latest"
# Deploy to all mainnet services
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=mainnet_services" \
-e "image_tag=mainnet-v1.0.0"
# Deploy to all taurus services
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=taurus_services" \
-e "image_tag=taurus-v1.0.0"The main Auto Drive deployment includes:
- Hasura GraphQL Engine: Database interface and API
- Backend API: Main application API
- Backend Worker: Background processing
- Backend Download API: File download handling
- Backend Download Worker: Download processing
- RabbitMQ: Message queue (optional profile)
- New Relic Agent: Monitoring
Services are organized into profiles:
- base: Core services (Hasura, New Relic)
- frontend: Frontend-related services (API, Worker)
- download: Download-related services (API, Worker)
- rabbit: RabbitMQ message queue
The gateway service provides:
- Unified API: Single interface for multiple networks
- File Access: GET
/file/:cidfor file retrieval - Folder Access: GET
/folder/:cidfor folder retrieval - Health Checks: Monitoring endpoints
The deployment uses Infisical for secrets management:
- Authentication: Universal auth with client ID/secret
- Secret Storage: Environment-specific paths in Infisical
- Configuration Paths:
- Auto Drive:
/[target_machines](e.g.,/auto_drive_mainnet_private)
- Auto Drive:
Key environment variables managed through Infisical:
BACKEND_IMAGE: Docker image for backend servicesDATABASE_URL: Database connection stringHASURA_GRAPHQL_ADMIN_SECRET: Hasura admin accessHASURA_GRAPHQL_JWT_SECRET: JWT authentication- Various port configurations and service settings
The deployment automatically:
- Backs up existing
.envfiles before updates - Creates timestamped backups in
~/env-archives/ - Maintains deployment history for rollback purposes
-
Infisical Authentication Failure
# Check Infisical credentials infisical login --method=universal-auth --client-id=YOUR_ID --client-secret=YOUR_SECRET # Verify project access infisical secrets --projectId YOUR_PROJECT_ID --path /auto_drive_mainnet_private --env prod
-
Docker Compose Failures
# Check service logs docker compose logs -f [service-name] # Verify image availability docker images | grep [image-name] # Check resource usage docker stats
-
SSH Connection Issues
# Test SSH connectivity ansible all -m ping # Check specific host ansible [hostname] -m ping
-
Environment Variable Issues
# Check .env file content cat ~/deploy/auto-drive/.env # Verify backup exists ls -la ~/env-archives/
Enable verbose output:
# Run with increased verbosity
ansible-playbook auto-drive-deployment.yml \
-e "target_machines=auto_drive_mainnet_private" \
-e "image_tag=latest" \
-vvvCheck deployment status:
# Check running containers
ansible all -m shell -a "docker ps"
# Check service health
ansible all -m shell -a "docker compose ps"- Stage First: Always deploy to staging environments before production
- Incremental Rollouts: Deploy to small subsets of production machines first
- Health Checks: Verify service health after each deployment
- Rollback Plan: Keep previous image tags for quick rollback
- Secret Management: Use Infisical for all sensitive configuration
- SSH Keys: Use SSH keys instead of passwords
- Network Security: Ensure proper firewall rules
- Regular Updates: Keep base images and dependencies updated
- Log Aggregation: Configure centralized logging (Loki integration included)
- Health Endpoints: Monitor service health endpoints
- Resource Monitoring: Track CPU, memory, and disk usage
- Alert Configuration: Set up alerts for critical failures
- Regular Backups: Schedule regular database and configuration backups
- Disaster Recovery: Test recovery procedures regularly
- Version Control: Keep deployment configurations in version control
- Documentation: Maintain up-to-date deployment documentation
- Resource Allocation: Monitor and adjust container resource limits
- Image Optimization: Use multi-stage builds for smaller images
- Caching: Implement appropriate caching strategies
- Load Balancing: Configure load balancing for high availability
# Check all hosts
ansible all -m ping
# Deploy to staging
ansible-playbook auto-drive-deployment.yml -e "target_machines=auto_drive_mainnet_staging" -e "image_tag=staging-latest"
# Setup new machines
ansible-playbook setup-infisical.yml -e "target_machines=new_machine_group"
# Check service status
ansible all -m shell -a "docker compose ps"| Tag | Purpose | Network | Environment |
|---|---|---|---|
auto_drive_mainnet_private |
Private mainnet services | Mainnet | Production |
auto_drive_mainnet_public |
Public mainnet services | Mainnet | Production |
auto_drive_taurus_private |
Private taurus services | Taurus | Production |
auto_drive_taurus_public |
Public taurus services | Taurus | Production |
auto_drive_mainnet_staging |
Mainnet staging | Mainnet | Staging |
auto_drive_taurus_staging |
Taurus staging | Taurus | Staging |
For additional support or questions, refer to the project documentation or contact the development team.