Skip to content

Commit 5592ff7

Browse files
committed
docs: [#220] add comprehensive documentation for release and run commands
1 parent de5d88b commit 5592ff7

File tree

5 files changed

+799
-41
lines changed

5 files changed

+799
-41
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
> -**Hetzner Cloud support** for production deployments
1313
> - ✅ Development and testing workflows
1414
> - ✅ Multi-provider architecture (provider selection via configuration)
15-
> - Application deployment (Torrust Tracker stack) - coming soon
15+
> - **Application deployment** (Torrust Tracker stack with Docker Compose)
1616
>
17-
> 📋 **MVP Goal:** After completing the [roadmap](docs/roadmap.md), we will have a fully automated deployment solution for Torrust Tracker with complete application stack management.
17+
> 📋 **MVP Goal:** After completing the [roadmap](docs/roadmap.md), we will have a fully automated deployment solution for Torrust Tracker with complete application stack management and multi-cloud provider support.
1818
1919
This Rust application provides automated deployment infrastructure for Torrust tracker projects. It supports **local development** with LXD and **production deployments** with Hetzner Cloud. The multi-provider architecture allows easy extension to additional cloud providers.
2020

@@ -28,12 +28,13 @@ This Rust application provides automated deployment infrastructure for Torrust t
2828
-**Fast, easy to install and use** local development solution
2929
-**No nested virtualization dependency** (CI compatibility)
3030
-**Multi-provider support** (LXD for local, Hetzner Cloud for production)
31+
-**Application stack deployment** (Torrust Tracker with Docker Compose)
3132

3233
**Future MVP Goals:** (See [roadmap](docs/roadmap.md))
3334

3435
- 🔄 **Additional cloud providers** (AWS, GCP, Azure)
35-
- 🔄 **Application stack deployment** (Torrust Tracker with Docker Compose)
3636
- 🔄 **Multi-environment management**
37+
- 🔄 **Enhanced observability** (monitoring, alerting, metrics)
3738

3839
## 🔧 Local Development Approach
3940

@@ -190,15 +191,16 @@ cargo run --bin e2e-tests-full -- --help
190191
191192
### 📖 Manual Deployment Steps
192193

193-
> **Infrastructure commands are now available!** You can create, provision, configure, test, and destroy deployment environments using the CLI.
194+
> **Complete deployment workflow is now available!** You can create, provision, configure, test, deploy, run, and destroy Torrust Tracker environments using the CLI.
194195
>
195196
> **Current Status:**
196197
>
197198
> -**Environment Management**: Create and manage deployment environments
198-
> -**Infrastructure Provisioning**: Provision VM infrastructure with LXD
199+
> -**Infrastructure Provisioning**: Provision VM infrastructure with LXD or Hetzner Cloud
199200
> -**Configuration**: Configure provisioned infrastructure (Docker, Docker Compose)
200201
> -**Verification**: Test deployment infrastructure
201-
> - ⚠️ **Application Deployment**: Not yet available - tracker application deployment coming soon
202+
> -**Application Deployment**: Deploy Torrust Tracker configuration and database
203+
> -**Service Management**: Start and manage tracker services
202204
>
203205
> **Available Commands:**
204206
>
@@ -220,7 +222,13 @@ cargo run --bin e2e-tests-full -- --help
220222
> # 6. Verify deployment infrastructure
221223
> torrust-tracker-deployer test my-environment
222224
>
223-
> # 7. Destroy environment when done
225+
> # 7. Deploy tracker application configuration
226+
> torrust-tracker-deployer release my-environment
227+
>
228+
> # 8. Start tracker services
229+
> torrust-tracker-deployer run my-environment
230+
>
231+
> # 9. Destroy environment when done
224232
> torrust-tracker-deployer destroy my-environment
225233
> ```
226234
>

docs/console-commands.md

Lines changed: 177 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88

99
- **Create Template**: Generate environment configuration template (JSON)
1010
- **Create Environment**: Create new deployment environment from configuration file
11-
- **Provision**: VM infrastructure provisioning with OpenTofu (LXD instances)
11+
- **Provision**: VM infrastructure provisioning with OpenTofu (LXD and Hetzner Cloud)
1212
- **Register**: Register existing instances as an alternative to provisioning (for pre-existing VMs, servers, or containers)
13-
- **Configure**: VM configuration with Docker and Docker Compose installation via Ansible
13+
- **Configure**: VM configuration with Docker, Docker Compose, and firewall via Ansible
1414
- **Test**: Verification of deployment infrastructure (cloud-init, Docker, Docker Compose)
15+
- **Release**: Deploy application configuration and files (tracker config, docker-compose stack)
16+
- **Run**: Start Torrust Tracker services and validate accessibility
1517
- **Destroy**: Infrastructure cleanup and environment destruction
16-
- Template rendering system (OpenTofu and Ansible templates)
18+
- Template rendering system (OpenTofu, Ansible, Tracker, Docker Compose templates)
1719
- SSH connectivity validation
1820
- Environment state management and persistence
1921

2022
### ⚠️ What's NOT Yet Implemented
2123

22-
- Application deployment (Docker Compose stack for Torrust Tracker)
23-
- Release command (deploy application files and configuration)
24-
- Run command (start/stop Torrust Tracker services)
2524
- Porcelain commands (high-level `deploy` command)
26-
- Multiple cloud provider support (only LXD currently supported)
25+
- Additional cloud providers (AWS, Azure, GCP)
2726

2827
## Deployment States
2928

@@ -38,36 +37,42 @@ The deployment follows a linear state progression:
3837

3938
Each command transitions the deployment to the next state.
4039

41-
## Current Deployment Workflow
40+
## Complete Deployment Workflow
4241

43-
The currently available commands for infrastructure management:
42+
The full deployment workflow with all implemented commands:
4443

4544
```bash
4645
# 1. Generate configuration template
47-
torrust-tracker-deployer create template my-env.json
46+
torrust-tracker-deployer create template --provider lxd > my-env.json
4847

49-
# 2. Edit my-env.json with your settings
48+
# 2. Edit my-env.json with your settings (SSH keys, tracker config, etc.)
5049

5150
# 3. Create environment from configuration
52-
torrust-tracker-deployer create environment -f my-env.json
51+
torrust-tracker-deployer create environment --env-file my-env.json
5352

5453
# 4a. Provision NEW VM infrastructure
5554
torrust-tracker-deployer provision my-environment
5655

5756
# 4b. OR Register EXISTING infrastructure (alternative to provision)
5857
torrust-tracker-deployer register my-environment --instance-ip 192.168.1.100
5958

60-
# 5. Configure system (Docker, Docker Compose)
59+
# 5. Configure system (Docker, Docker Compose, firewall)
6160
torrust-tracker-deployer configure my-environment
6261

6362
# 6. Verify deployment infrastructure
6463
torrust-tracker-deployer test my-environment
6564

66-
# 7. Destroy environment when done
65+
# 7. Deploy application configuration and files
66+
torrust-tracker-deployer release my-environment
67+
68+
# 8. Start Torrust Tracker services
69+
torrust-tracker-deployer run my-environment
70+
71+
# 9. Destroy environment when done
6772
torrust-tracker-deployer destroy my-environment
6873
```
6974

70-
This workflow deploys VM infrastructure with Docker and Docker Compose installed, ready for application deployment (coming soon with `release` and `run` commands).
75+
This workflow deploys a complete Torrust Tracker instance with all configuration and services running.
7176

7277
## Hybrid Command Architecture
7378

@@ -119,15 +124,15 @@ torrust-tracker-deployer list # List all environments (not yet implem
119124
# Environment Management
120125
torrust-tracker-deployer create template [PATH] # ✅ Generate configuration template
121126
torrust-tracker-deployer create environment -f <file> # ✅ Create environment from config
122-
torrust-tracker-deployer status <env> # Show environment info (not yet implemented)
123-
torrust-tracker-deployer destroy <env> # ✅ Clean up infrastructure
124-
125-
# Porcelain Commands (High-Level) - Future
126-
torrust-tracker-deployer deploy <env> # Smart deployment from current state (not yet implemented)
127-
128127
# Plumbing Commands (Low-Level)
129128
torrust-tracker-deployer provision <env> # ✅ Create VM infrastructure
130129
torrust-tracker-deployer register <env> --instance-ip <IP> # ✅ Register existing infrastructure
130+
torrust-tracker-deployer configure <env> # ✅ Setup VM (Docker, Docker Compose, firewall)
131+
torrust-tracker-deployer release <env> # ✅ Deploy application files and configuration
132+
torrust-tracker-deployer run <env> # ✅ Start Torrust Tracker services
133+
134+
# Validation
135+
torrust-tracker-deployer test <env> # ✅ Verify infrastructure (cloud-init, Docker, Docker Compose)
131136
torrust-tracker-deployer configure <env> # ✅ Setup VM (Docker, Docker Compose)
132137
torrust-tracker-deployer release <env> # Deploy application files (not yet implemented)
133138
torrust-tracker-deployer run <env> # Start application stack (not yet implemented)
@@ -521,6 +526,157 @@ torrust-tracker-deployer test my-environment
521526

522527
---
523528

529+
### `release` - Deploy Application Configuration
530+
531+
**Status**: ✅ Implemented
532+
**State Transition**: `Configured``Released`
533+
**Purpose**: Deploy application configuration files and prepare the environment for running services.
534+
535+
```bash
536+
torrust-tracker-deployer release <environment>
537+
```
538+
539+
**Current Implementation**:
540+
541+
- Creates storage directory structure on VM (`/opt/torrust/storage/tracker/`)
542+
- Initializes SQLite database for tracker
543+
- Renders tracker configuration from environment settings (`tracker.toml`)
544+
- Generates Docker Compose environment variables (`.env`)
545+
- Deploys all configuration files to VM
546+
- Synchronizes Docker Compose stack files
547+
548+
**What Gets Deployed**:
549+
550+
- Tracker configuration: `/opt/torrust/storage/tracker/etc/tracker.toml`
551+
- Database file: `/opt/torrust/storage/tracker/lib/database/tracker.db`
552+
- Environment variables: `/opt/torrust/.env`
553+
- Docker Compose stack: `/opt/torrust/docker-compose.yml`
554+
555+
**Use Cases**:
556+
557+
- Deploy application after infrastructure is configured
558+
- Update tracker configuration (re-run after editing environment.json)
559+
- Prepare environment for running services
560+
561+
**Example**:
562+
563+
```bash
564+
# Deploy application configuration
565+
torrust-tracker-deployer release my-environment
566+
567+
# Output:
568+
# ✓ Creating tracker storage directories...
569+
# ✓ Initializing tracker database...
570+
# ✓ Rendering tracker templates...
571+
# ✓ Deploying tracker configuration...
572+
# ✓ Deploying Docker Compose files...
573+
# ✓ Release complete - environment ready to run
574+
```
575+
576+
**Configuration Source**:
577+
578+
The release command uses tracker configuration from your environment JSON:
579+
580+
```json
581+
{
582+
"tracker": {
583+
"core": {
584+
"database_name": "tracker.db",
585+
"private": false
586+
},
587+
"udp_trackers": [{ "bind_address": "0.0.0.0:6868" }],
588+
"http_trackers": [{ "bind_address": "0.0.0.0:7070" }],
589+
"http_api": {
590+
"bind_address": "0.0.0.0:1212",
591+
"admin_token": "MyAccessToken"
592+
}
593+
}
594+
}
595+
```
596+
597+
**Idempotent Operation**:
598+
599+
- Can be re-run safely to update configuration
600+
- Existing database is preserved
601+
- Configuration files are overwritten with new values
602+
603+
---
604+
605+
### `run` - Start Tracker Services
606+
607+
**Status**: ✅ Implemented
608+
**State Transition**: `Released``Running`
609+
**Purpose**: Start the Torrust Tracker application services and validate they are running.
610+
611+
```bash
612+
torrust-tracker-deployer run <environment>
613+
```
614+
615+
**Current Implementation**:
616+
617+
- Starts Docker Compose services (`docker compose up -d`)
618+
- Validates services are running via Docker status
619+
- Performs external health checks on tracker API
620+
- Verifies firewall allows external access
621+
622+
**Services Started**:
623+
624+
- **Tracker container** (`torrust/tracker:develop`)
625+
- UDP Tracker endpoints (ports 6868, 6969 by default)
626+
- HTTP Tracker endpoint (port 7070 by default)
627+
- HTTP API endpoint (port 1212 by default)
628+
629+
**Health Checks Performed**:
630+
631+
1. **Docker Compose Status** - Verifies containers are running
632+
2. **Tracker API Health** (required) - Tests external accessibility of HTTP API
633+
- Endpoint: `http://<vm-ip>:1212/api/health_check`
634+
- Validates service functionality AND firewall configuration
635+
3. **HTTP Tracker Health** (optional) - Tests external accessibility of HTTP tracker
636+
- Endpoint: `http://<vm-ip>:7070/api/health_check`
637+
- Warning only if check fails (not all versions have endpoint)
638+
639+
**Use Cases**:
640+
641+
- Start tracker services after release
642+
- Restart services after configuration changes
643+
- Validate tracker is accessible externally
644+
645+
**Example**:
646+
647+
```bash
648+
# Start tracker services
649+
torrust-tracker-deployer run my-environment
650+
651+
# Output:
652+
# ✓ Starting Docker Compose services...
653+
# ✓ Validating services are running...
654+
# ✓ Checking tracker API accessibility...
655+
# ✓ Tracker services running and accessible
656+
```
657+
658+
**Verification**:
659+
660+
After running, you can access the tracker:
661+
662+
```bash
663+
# Get VM IP
664+
VM_IP=$(torrust-tracker-deployer show my-environment | grep 'IP Address' | awk '{print $3}')
665+
666+
# Test tracker API
667+
curl http://$VM_IP:1212/api/health_check
668+
669+
# Get tracker statistics
670+
curl http://$VM_IP:1212/api/v1/stats
671+
```
672+
673+
**Announce URLs**:
674+
675+
- UDP: `udp://<vm-ip>:6868/announce` or `udp://<vm-ip>:6969/announce`
676+
- HTTP: `http://<vm-ip>:7070/announce`
677+
678+
---
679+
524680
### `status` - Environment Information
525681

526682
**Status**: ❌ Not Implemented

docs/user-guide/commands/README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ This directory contains detailed guides for all Torrust Tracker Deployer command
1616
- **[configure](configure.md)** - Configure provisioned infrastructure
1717
- **[test](test.md)** - Verify deployment infrastructure
1818

19+
### Application Deployment
20+
21+
- **[release](release.md)** - Deploy application configuration and files
22+
- **[run](run.md)** - Start Torrust Tracker services
23+
1924
### Environment Cleanup
2025

2126
- **[destroy](destroy.md)** - Destroy deployment environment
@@ -29,10 +34,11 @@ The typical command sequence for a complete deployment:
2934
2. (edit template) → Customize your settings
3035
3. create environment → Create environment from config
3136
4. provision → Provision VM infrastructure
32-
5. configure → Install Docker, Docker Compose
37+
5. configure → Install Docker, Docker Compose, configure firewall
3338
6. test → Verify infrastructure readiness
34-
7. (deploy app) → Deploy Torrust Tracker (coming soon)
35-
8. destroy → Clean up when done
39+
7. release → Deploy application configuration and files
40+
8. run → Start Torrust Tracker services
41+
9. destroy → Clean up when done
3642
```
3743

3844
## Command Categories
@@ -45,6 +51,9 @@ These commands provide fine-grained control over each deployment step:
4551
- `provision`
4652
- `configure`
4753
- `test`
54+
- `release`
55+
- `run`
56+
- `destroy`
4857
- `destroy`
4958

5059
**Best for**: CI/CD pipelines, automation, advanced users, debugging
@@ -57,16 +66,18 @@ Simplified commands that orchestrate multiple plumbing commands:
5766

5867
**Best for**: Quick deployments, beginners, interactive use
5968

60-
## Quick Reference
61-
62-
| Command | State Transition | Description |
63-
| -------------------- | ------------------------ | ------------------------ |
64-
| `create template` | N/A → Template | Generate config template |
65-
| `create environment` | Template → Created | Create environment |
66-
| `provision` | Created → Provisioned | Provision infrastructure |
67-
| `configure` | Provisioned → Configured | Install software |
68-
| `test` | (validation only) | Verify infrastructure |
69-
| `destroy` | Any → Destroyed | Clean up resources |
69+
| Command | State Transition | Description |
70+
| -------------------- | ------------------------ | -------------------------- |
71+
| `create template` | N/A → Template | Generate config template |
72+
| `create environment` | Template → Created | Create environment |
73+
| `provision` | Created → Provisioned | Provision infrastructure |
74+
| `configure` | Provisioned → Configured | Install software, firewall |
75+
| `test` | (validation only) | Verify infrastructure |
76+
| `release` | Configured → Released | Deploy application files |
77+
| `run` | Released → Running | Start tracker services |
78+
| `destroy` | Any → Destroyed | Clean up resources |
79+
| `test` | (validation only) | Verify infrastructure |
80+
| `destroy` | Any → Destroyed | Clean up resources |
7081

7182
## Getting Started
7283

0 commit comments

Comments
 (0)