|
| 1 | +# OpenRAG Ansible Deployment |
| 2 | + |
| 3 | +> **📝 Note**: This repository now uses **modular playbooks** for better organization and flexibility. |
| 4 | +> All playbooks have been moved to the `playbooks/` directory. |
| 5 | +> For detailed information about the modular approach, see [README-modular.md](README-modular.md). |
| 6 | +
|
| 7 | +This directory contains Ansible playbooks and scripts to automatically set up the OpenRAG environment on one or more servers. |
| 8 | + |
| 9 | +These scripts are designed for installation on fresh production servers. |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- **Automated Docker installation** |
| 14 | +- **NVIDIA GPU support** |
| 15 | +- **Complete OpenRAG deployment** |
| 16 | +- **Multi-server support** |
| 17 | + |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +### 1. Prerequisites |
| 21 | + |
| 22 | +- Ansible installed on your control machine (automatically installed by deploy.sh if missing) |
| 23 | +- SSH access to target servers (if deploying remotely) |
| 24 | +- Ubuntu 20.04+ or similar Linux distribution on target servers |
| 25 | +- For remote deployment: `inventory.ini.example` file from the OpenRAG repository |
| 26 | + |
| 27 | +### 2. Local Deployment (Easiest) |
| 28 | + |
| 29 | +```bash |
| 30 | +cd ansible/ |
| 31 | +./deploy.sh |
| 32 | +# Choose option 1: "Deploy to local machine" |
| 33 | +# Select CPU-only or GPU-enabled deployment when prompted |
| 34 | +``` |
| 35 | + |
| 36 | +The local deployment will: |
| 37 | +- Prompt you to choose between CPU-only or GPU-enabled deployment |
| 38 | +- Handle all necessary configurations and installs automatically |
| 39 | +- Start all services |
| 40 | + |
| 41 | +### 3. Remote Deployment |
| 42 | + |
| 43 | +1. **Create the inventory file (on the control machine):** |
| 44 | + ```bash |
| 45 | + # Rename the example inventory file |
| 46 | + cp inventory.ini.example inventory.ini |
| 47 | + |
| 48 | + # Edit the inventory file |
| 49 | + nano inventory.ini |
| 50 | + ``` |
| 51 | + |
| 52 | +2. **Configure your servers:** |
| 53 | + ```ini |
| 54 | + [gpu_servers] |
| 55 | + gpu-server1 ansible_host=192.168.1.100 ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa |
| 56 | + gpu-server2 ansible_host=192.168.1.101 ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa |
| 57 | + |
| 58 | + [cpu_servers] |
| 59 | + cpu-server1 ansible_host=192.168.1.102 ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa |
| 60 | + |
| 61 | + [all:vars] |
| 62 | + ansible_python_interpreter=/usr/bin/python3 |
| 63 | + ``` |
| 64 | + |
| 65 | +3. **Run the deployment:** |
| 66 | + ```bash |
| 67 | + ./deploy.sh |
| 68 | + # Choose option 2: "Deploy remotely" |
| 69 | + ``` |
| 70 | + |
| 71 | +## Files Overview |
| 72 | + |
| 73 | +### Playbooks |
| 74 | + |
| 75 | +- **`playbook.yml`** - Main deployment playbook with separate GPU-enabled and CPU-only server configurations |
| 76 | + |
| 77 | +### Inventory Files |
| 78 | + |
| 79 | +- **`inventory.ini.example`** - Example inventory template for remote deployment |
| 80 | +- **`inventory.ini`** - Generated automatically for local deployment or manually created for remote deployment |
| 81 | + |
| 82 | +### Configuration |
| 83 | + |
| 84 | +- **`ansible.cfg`** - Ansible configuration settings |
| 85 | + |
| 86 | +### Scripts |
| 87 | + |
| 88 | +- **`deploy.sh`** - Interactive deployment and management |
| 89 | + |
| 90 | +## Manual Deployment |
| 91 | + |
| 92 | +If you prefer to run Ansible commands directly: |
| 93 | + |
| 94 | +### Local/Remote Deployment |
| 95 | +```bash |
| 96 | +# Create inventory first |
| 97 | +ansible-playbook -i inventory.ini playbook.yml --ask-become-pass |
| 98 | +``` |
| 99 | + |
| 100 | +### Check Status |
| 101 | +```bash |
| 102 | +ansible all -i inventory.ini -m shell -a "docker ps" --become |
| 103 | +``` |
| 104 | + |
| 105 | +## Service Management |
| 106 | + |
| 107 | +The deployment script provides several management options: |
| 108 | + |
| 109 | +### Interactive Mode |
| 110 | +```bash |
| 111 | +./deploy.sh |
| 112 | +``` |
| 113 | + |
| 114 | +### Command Line Mode |
| 115 | +```bash |
| 116 | +# Deploy locally |
| 117 | +./deploy.sh deploy-local |
| 118 | + |
| 119 | +# Deploy remotely |
| 120 | +./deploy.sh deploy-remote |
| 121 | + |
| 122 | +# Check status |
| 123 | +./deploy.sh status |
| 124 | + |
| 125 | +# Stop services |
| 126 | +./deploy.sh stop |
| 127 | + |
| 128 | +# Start services |
| 129 | +./deploy.sh start |
| 130 | + |
| 131 | +# View logs |
| 132 | +./deploy.sh logs [service_name] |
| 133 | + |
| 134 | +# Update deployment |
| 135 | +./deploy.sh update |
| 136 | + |
| 137 | +# Complete removal |
| 138 | +./deploy.sh remove-all |
| 139 | +``` |
| 140 | + |
| 141 | +## What Gets Installed |
| 142 | + |
| 143 | +### System Packages |
| 144 | +- Docker CE with Compose plugin |
| 145 | +- NVIDIA drivers (if GPU detected and GPU server group is used) |
| 146 | +- NVIDIA Container Toolkit (for GPU servers) |
| 147 | +- Python 3 with pip and uv package manager |
| 148 | +- Essential development tools |
| 149 | + |
| 150 | +### OpenRAG Components |
| 151 | +- Complete OpenRAG codebase from GitHub |
| 152 | +- All required Python dependencies installed via `uv` |
| 153 | +- Docker containers for OpenRAG services with appropriate profiles: |
| 154 | + - GPU servers: Default profile (includes GPU-accelerated services) |
| 155 | + - CPU servers: CPU profile (CPU-only services) |
| 156 | + |
| 157 | +### Directory Structure |
| 158 | +``` |
| 159 | +/home/[user]/openrag/ |
| 160 | +├── data/ # Document storage |
| 161 | +├── db/ # Database files |
| 162 | +├── logs/ # Application logs |
| 163 | +├── .hydra_config/ # Hydra configuration cache |
| 164 | +├── model_weights/ # Cached model files |
| 165 | +├── vdb/volumes/ # Vector database volumes |
| 166 | +├── .env # Environment configuration |
| 167 | +└── ... # OpenRAG source code |
| 168 | +``` |
| 169 | + |
| 170 | +## Configuration |
| 171 | + |
| 172 | +### Environment Variables |
| 173 | + |
| 174 | +The deployment automatically creates a `.env` file from `.env.example` or copies a local `.env` file if present. Key variables to customize: |
| 175 | + |
| 176 | +```bash |
| 177 | +# LLM Configuration |
| 178 | +BASE_URL=http://your-llm-endpoint |
| 179 | +API_KEY=your-api-key |
| 180 | +MODEL=your-model-name |
| 181 | + |
| 182 | +# Application Settings |
| 183 | +APP_PORT=8080 |
| 184 | +RETRIEVER_TOP_K=20 |
| 185 | + |
| 186 | +# Embedder Settings |
| 187 | +EMBEDDER_MODEL_NAME=Qwen/Qwen3-Embedding-0.6B |
| 188 | +``` |
| 189 | + |
| 190 | +### Version Configuration |
| 191 | + |
| 192 | +The playbook uses these default versions (configurable via inventory variables): |
| 193 | + |
| 194 | +```yaml |
| 195 | +# Docker and NVIDIA versions |
| 196 | +docker_compose_version: "2.21.0" |
| 197 | +nvidia_driver_version: "535" |
| 198 | +docker_ce_version: "latest" |
| 199 | +nvidia_container_toolkit_version: "1.17.8-1" |
| 200 | +``` |
| 201 | +
|
| 202 | +### Inventory Variables |
| 203 | +
|
| 204 | +You can set variables in your inventory file: |
| 205 | +
|
| 206 | +```ini |
| 207 | +[gpu_servers:vars] |
| 208 | +nvidia_driver_version=535 |
| 209 | +project_user=ubuntu |
| 210 | +project_path=/home/ubuntu/openrag |
| 211 | + |
| 212 | +[cpu_servers:vars] |
| 213 | +project_user=ubuntu |
| 214 | +project_path=/home/ubuntu/openrag |
| 215 | + |
| 216 | +[all:vars] |
| 217 | +ansible_python_interpreter=/usr/bin/python3 |
| 218 | +``` |
| 219 | + |
| 220 | +## Troubleshooting |
| 221 | + |
| 222 | +### Common Issues |
| 223 | + |
| 224 | +1. **Docker permission denied** |
| 225 | + ```bash |
| 226 | + # Re-login to apply docker group membership |
| 227 | + sudo su - $USER |
| 228 | + ``` |
| 229 | + |
| 230 | +2. **NVIDIA driver installation fails** |
| 231 | + ```bash |
| 232 | + # Check GPU compatibility |
| 233 | + lspci | grep -i nvidia |
| 234 | + ``` |
| 235 | + |
| 236 | +3. **Services not starting** |
| 237 | + ```bash |
| 238 | + # Check logs |
| 239 | + docker compose logs |
| 240 | + ``` |
| 241 | + |
| 242 | +### Manual Recovery |
| 243 | + |
| 244 | +If something goes wrong, you can manually clean up: |
| 245 | + |
| 246 | +```bash |
| 247 | +# Stop all containers |
| 248 | +docker compose down |
| 249 | + |
| 250 | +# Remove containers and images |
| 251 | +docker system prune -a |
| 252 | + |
| 253 | +# Re-run deployment |
| 254 | +./deploy.sh |
| 255 | +``` |
| 256 | + |
| 257 | +### Complete System Reset |
| 258 | + |
| 259 | +For a complete removal of all components (Docker, NVIDIA drivers, OpenRAG): |
| 260 | + |
| 261 | +```bash |
| 262 | +# Use the deployment script's removal option |
| 263 | +./deploy.sh remove-all |
| 264 | +``` |
| 265 | + |
| 266 | +**Warning**: This will remove Docker, NVIDIA drivers, and all related components. Use with caution! |
| 267 | + |
| 268 | +For OpenRAG application issues, refer to the main project documentation. |
0 commit comments