Commit 3a31f9f
committed
cff2e0d docs: [#220] update documentation with real command outputs and state management warnings (Jose Celano)
aacdcd6 chore: [#220] remove completed implementation plan (Jose Celano)
fbfeb65 docs: [#220] mark Phase 3 complete - infrastructure reorganization (Jose Celano)
32d31d7 docs: [#220] add ADR for infrastructure module organization (Jose Celano)
901a817 refactor: [#220] update imports to use external_validators path (Jose Celano)
e86fe48 refactor: [#220] update infrastructure exports for external validators (Jose Celano)
dbe2876 refactor: [#220] move running_services validator to external_validators (Jose Celano)
d6a5c3b refactor: [#220] create external_validators module structure (Jose Celano)
223b83d docs: [#220] mark Step 4.4 complete - all validation passed (Jose Celano)
0c14fd6 docs: [#220] update architecture docs for running services validator (Jose Celano)
20afd81 docs: [#220] update run command documentation (Jose Celano)
fbb300b docs: [#220] mark Phase 2 as complete in implementation plan (Jose Celano)
3be2c3a step: [#220] add unit tests for multiple HTTP tracker support (Jose Celano)
2ca1e04 step: [#220] update RunningServicesValidator for multiple HTTP trackers (Jose Celano)
7312107 docs: [#220] mark Phase 1 complete - port 0 validation (Jose Celano)
ff04fe7 step: [#220] add port 0 validation tests (Jose Celano)
877a550 docs: [#220] mark Step 1.3 complete (Jose Celano)
2d8e8f4 step: [#220] add port 0 validation in conversion methods (Jose Celano)
b9a739b docs: [#220] mark Step 1.2 complete (Jose Celano)
1cbb942 step: [#220] add DynamicPortNotSupported error variant (Jose Celano)
27557f0 docs: [#220] add ADR for port zero not supported in bind addresses (Jose Celano)
5cc10f5 docs: [#220] mark Phase 0 complete - architecture fix done (Jose Celano)
01be3af step: [#220] update EnvironmentCreationConfig to use TrackerSection (Jose Celano)
de1fdb4 step: [#220] update domain types to use SocketAddr (Jose Celano)
b985a09 step: [#220] implement TrackerSection DTO (Jose Celano)
3234f16 step: [#220] implement TrackerCoreSection DTO (Jose Celano)
a6741cf step: [#220] implement HttpApiSection DTO (Jose Celano)
701cc28 step: [#220] implement HttpTrackerSection DTO (Jose Celano)
6c86c44 step: [#220] implement UdpTrackerSection DTO (Jose Celano)
d70ab59 step: [#220] create tracker DTO module structure (Jose Celano)
b908a24 docs: [#220] add implementation plan for test command architecture improvements (Jose Celano)
a39ba13 feat: [#220] enhance test command with external health checks (Jose Celano)
8e0e096 fix: [#220] correct netstat flags and add tulnp to project dictionary (Jose Celano)
5592ff7 docs: [#220] add comprehensive documentation for release and run commands (Jose Celano)
de5d88b docs: update workflow badges to match renamed workflow files (Jose Celano)
2827ab8 docs: add cross-references between template documentation files (Jose Celano)
9d64e9b feat: [#220] make HTTP API bind address configurable in tracker template (Jose Celano)
893ac72 docs: [#220] reorganize E2E testing documentation into structured directory (Jose Celano)
c7b27ce docs: [#220] document decision to use single Docker image for sequential E2E testing (Jose Celano)
61a712d refactor: [#220] update cargo aliases for renamed E2E test binaries (Jose Celano)
1e957ba refactor: [#220] rename E2E test binaries to better reflect their purpose (Jose Celano)
13cca4c refactor: [#220] make E2eConfigEnvironment single source of truth for E2E test configuration (Jose Celano)
638561e refactor: [#220] remove unused update_environment_ssh_port function (Jose Celano)
862b95d refactor: [#220] remove unused with_working_dir functions (Jose Celano)
e22e601 refactor: [#220] consolidate create_test_environment_config into shared function (Jose Celano)
e704f27 refactor: [#220] organize E2E tests into module structure (Jose Celano)
b7e3527 refactor: [#220] return JSON string directly from config helper (Jose Celano)
67efd7c feat: [#220] add default tracker configuration to environment template (Jose Celano)
430c52e docs: [#221] add ADR for register SSH port override and update E2E testing guide (Jose Celano)
f16d6cd feat: [#221] add optional --ssh-port argument to register command (Jose Celano)
83254bb refactor: [#221] separate E2E configuration from runtime state with bridge networking (Jose Celano)
35a256f refactor: [#220] simplify RunningServicesValidator to external-only validation with parameterized ports (Jose Celano)
9453e80 feat: [#220] add .env file check to run-compose-services playbook (Jose Celano)
b947d1b refactor: [#220] remove default UDP tracker on port 6868 (Jose Celano)
3f6721b feat: [#220] wire tracker config through provision workflow (Phase 7 complete) (Jose Celano)
3d397c8 chore: delete mmanual test file (Jose Celano)
9c7daac docs: [#220] exclude generated folders from taplo and update linting docs (Jose Celano)
8294d9e fix: [#220] clippy doc_markdown and rustdoc warnings for Phase 7 (Jose Celano)
6939553 feat: [#220] Phase 7 infrastructure for tracker firewall configuration (partial) (Jose Celano)
52d7c2a feat: [#220] make tracker configuration mandatory in environment config (Jose Celano)
748951d docs: [#220] mark Phase 5 complete in implementation progress tracking (Jose Celano)
59e3762 feat: [#220] replace nginx demo with Torrust Tracker in docker-compose (Phase 5) (Jose Celano)
4957b01 docs: [#220] mark Phase 4 complete in implementation progress tracking (Jose Celano)
659e407 refactor: [#220] reorganize tracker template structure to match ansible pattern (Jose Celano)
aa1c494 feat: [#220] add docker compose .env template with project generator pattern (Jose Celano)
794ef06 feat: [#220] implement Phase 2 - initialize tracker SQLite database (Jose Celano)
1b83dfb docs: [#220] add Phase 1 manual E2E test results (Jose Celano)
311d987 feat: [#220] implement Phase 1 - create tracker storage directories (Jose Celano)
dff5a09 docs: [#220] mark Phase 0 as completed (Jose Celano)
2d5625c refactor: [#220] rename external_tools module to templating (Jose Celano)
Pull request description:
## Summary
This PR implements the complete **Tracker Slice** for Release and Run commands, replacing the demo nginx service with a fully functional Torrust Tracker deployment. The implementation follows an incremental, testable approach with 8 phases, all of which have been successfully completed.
## What's Been Implemented
### ✅ All 8 Phases Complete
**Phase 0: Module Refactoring (Completed)**
- Renamed `src/infrastructure/external_tools/` → `src/infrastructure/templating/`
- Better reflects the module's purpose (template rendering logic)
**Phase 1: Storage Directory Creation (Completed)**
- Ansible playbook creates tracker storage structure: `/opt/torrust/storage/tracker/{etc,lib/database,log}`
- Integrated into ReleaseCommand workflow
- Manual E2E test verified directory creation with correct ownership and permissions
**Phase 2: SQLite Database Initialization (Completed)**
- Ansible playbook initializes SQLite database file (`tracker.db`)
- Empty database file created with proper permissions (0644, torrust:torrust)
- Integrated into ReleaseCommand workflow after storage creation
**Phase 3: Docker Compose Environment Variables (Completed)**
- Implemented `.env` file generation using Project Generator pattern
- Created `EnvContext`, `EnvTemplate`, and `EnvRenderer` components
- Refactored to three-layer architecture (Wrapper → Renderer → Generator)
- `.env` file deployed to `/opt/torrust/.env` with tracker configuration
**Phase 4: Tracker Configuration Template (Completed)**
- Created `templates/tracker/tracker.toml.tera` with Torrust Tracker configuration
- Implemented `TrackerProjectGenerator` following Project Generator pattern
- Created `RenderTrackerTemplatesStep` and `DeployTrackerConfigStep`
- Configuration deployed to `/opt/torrust/storage/tracker/etc/tracker.toml`
**Phase 5: Docker Compose Service Replacement (Completed)**
- Replaced nginx demo service with Torrust Tracker in docker-compose
- Configured UDP tracker ports (6969), HTTP tracker (7070), and HTTP API (1212)
- Volume mounts for storage directories (lib, log, etc)
- Environment variable integration for configuration
**Phase 6: Environment Configuration Support (Completed)**
- Added `TrackerConfig` schema to environment configuration
- Users can configure: UDP trackers, HTTP trackers, private/public mode, API admin token
- All templates dynamically populated from environment config
- Template generation uses tracker configuration for variable substitution
**Phase 7: Firewall Configuration (Completed)**
- Ansible playbook configures UFW firewall for tracker ports
- Opens UDP tracker ports, HTTP tracker ports, and HTTP API port
- Port extraction from environment configuration
- Integrated into ConfigureCommand workflow
- Manual E2E test verified all firewall rules correctly applied
**Phase 8: E2E Test Updates (Completed)**
- Updated `RunningServicesValidator` for external-only validation
- Checks tracker HTTP API health endpoint (`http://<vm-ip>:1212/api/health_check`)
- Checks HTTP tracker health endpoint (`http://<vm-ip>:7070/api/health_check`)
- Simplified to external validation (proves service AND firewall working)
- Refactored validation code for better maintainability
### Architecture Improvements
**Domain-Driven Design (DDD)**
- Proper layer separation: Domain DTOs, Infrastructure templates, Application workflows
- Created tracker DTO module with validation (port 0 not supported, documented in ADR)
- Multiple HTTP tracker support with external validation for each instance
**Infrastructure Module Organization**
- Created `external_validators/` module for direct HTTP validation (no SSH required)
- Better separation: `remote_actions/` (via SSH) vs `external_validators/` (direct HTTP)
- Documented in ADR for future maintainability
**Template System**
- Consistent Project Generator pattern across all template modules
- Three-layer architecture: Wrapper → Renderer → Generator
- Static templates explicitly registered, dynamic templates with `.tera` extension
## Testing
### Manual E2E Testing
All phases manually tested with complete verification:
- ✅ Storage directories created with correct permissions
- ✅ SQLite database initialized
- ✅ `.env` file deployed with tracker configuration
- ✅ `tracker.toml` configuration deployed
- ✅ Tracker container running with all ports exposed
- ✅ Firewall rules applied (UDP 6969, HTTP 7070, API 1212)
- ✅ External HTTP health checks passing
### Automated E2E Testing
- ✅ Full E2E test suite passing (complete workflow validation)
- ✅ Infrastructure lifecycle tests passing (provisioning and destruction)
- ✅ Deployment workflow tests passing (configuration, release, run)
- ✅ All 1424 unit tests passing
- ✅ All 40 integration tests passing
- ✅ All pre-commit checks passing
### Real-World Validation
- ✅ Tracker HTTP API accessible: `curl http://<vm-ip>:1212/api/health_check` returns HTTP 200
- ✅ HTTP Tracker accessible: `curl http://<vm-ip>:7070/api/health_check` returns HTTP 200
- ✅ All tracker ports open in firewall (verified with `sudo ufw status`)
- ✅ Docker services running: `docker compose ps` shows tracker in "running" state
## Documentation Updates
- ✅ Complete implementation plan with all 8 phases documented
- ✅ Manual testing workflow guide with real command outputs
- ✅ Architecture Decision Records (ADRs) for key design decisions
- ✅ Updated quick-start guide with tracker deployment workflow
- ✅ Updated manual E2E testing documentation
## Acceptance Criteria
All acceptance criteria from issue #220 have been met:
**Quality Checks**
- ✅ Pre-commit checks pass
- ✅ All linters passing (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck)
- ✅ All unit, integration, and E2E tests passing
**Functional Requirements**
- ✅ Storage directories created on VM
- ✅ SQLite database initialized
- ✅ Docker compose `.env` file deployed
- ✅ Tracker configuration file deployed
- ✅ Docker compose service updated with tracker
- ✅ Firewall configured for all tracker ports
- ✅ Tracker container starts successfully
- ✅ Tracker HTTP API responds to health checks
- ✅ Tracker ports accessible externally
**Configuration Requirements**
- ✅ Environment config supports tracker configuration
- ✅ Users can specify UDP/HTTP tracker instances
- ✅ Private/public mode configurable
- ✅ Database name configurable
- ✅ API admin token configurable
- ✅ Template variables correctly substituted
**Architecture Requirements**
- ✅ Tracker templates isolated in separate module
- ✅ Project Generator pattern implemented
- ✅ Static templates registered in renderer
- ✅ No mixing of tracker and docker-compose templates
**Testing Requirements**
- ✅ All phases manually testable
- ✅ E2E tests updated for tracker validation
- ✅ Example environment files demonstrate configuration
## Related Documentation
- Issue: #220
- Parent Epic: #216
- Implementation Plan: [docs/issues/220-tracker-slice-release-run-commands.md](https://github.com/torrust/torrust-tracker-deployer/blob/220-tracker-slice-release-run-commands/docs/issues/220-tracker-slice-release-run-commands.md)
- Manual Testing Guide: [docs/e2e-testing/manual-testing.md](https://github.com/torrust/torrust-tracker-deployer/blob/220-tracker-slice-release-run-commands/docs/e2e-testing/manual-testing.md)
- Quick Start Guide: [docs/user-guide/quick-start.md](https://github.com/torrust/torrust-tracker-deployer/blob/220-tracker-slice-release-run-commands/docs/user-guide/quick-start.md)
## Deployment Workflow
The complete workflow for deploying a Torrust Tracker:
```bash
# 1. Create environment from template
cargo run -- create template --provider lxd > envs/my-tracker.json
# 2. Edit environment configuration with your values
# 3. Create environment
cargo run -- create environment --env-file envs/my-tracker.json
# 4. Provision VM
cargo run -- provision my-tracker
# 5. Configure VM (installs Docker, configures firewall, creates storage)
cargo run -- configure my-tracker
# 6. Release (deploys configurations and docker-compose)
cargo run -- release my-tracker
# 7. Run services
cargo run -- run my-tracker
# 8. Verify deployment
VM_IP=$(cargo run -- show my-tracker | grep 'IP Address' | awk '{print $3}')
curl http://$VM_IP:1212/api/health_check # Tracker API
curl http://$VM_IP:7070/api/health_check # HTTP Tracker
```
## Next Steps
This PR is ready to merge. All phases completed, all tests passing, all documentation updated.
Future enhancements (not in this PR):
- Additional tracker configuration options (database driver, intervals, logging)
- Support for multiple tracker instances
- Tracker management commands (status, logs, restart)
- Integration with Index and Grafana services
Closes #220
ACKs for top commit:
josecelano:
ACK cff2e0d
Tree-SHA512: 991c96c81321f38bc53ece9eff2be6406c23b42a7d591b5f0fd115f207048167decb96ad28149dd205fae45044c23a05e39eedc6048bb8b247fe502f557ce734
File tree
194 files changed
+12090
-2588
lines changed- .cargo
- .github/workflows
- docker/provisioned-instance
- docs
- contributing
- testing
- decisions
- e2e-testing
- implementation-plans
- issues
- technical
- user-guide
- commands
- packages
- scripts
- src
- adapters
- application
- command_handlers
- configure
- create
- config
- tracker
- tests
- provision
- tests
- register
- release
- test
- services
- steps
- application
- rendering
- system
- bin
- domain
- environment
- state
- template
- tracker
- infrastructure
- external_tools
- ansible/template/wrappers/variables
- docker_compose/template
- renderer
- external_validators
- remote_actions
- validators
- templating
- ansible
- template
- renderer
- wrappers
- inventory
- context
- variables
- docker_compose
- template
- renderer
- wrappers
- env
- tofu
- template
- common
- renderer
- wrappers
- cloud_init
- providers
- hetzner
- wrappers
- variables
- lxd
- wrappers
- variables
- tracker
- template
- renderer
- wrapper
- tracker_config
- presentation
- controllers
- create/subcommands/environment
- register
- tests
- dispatch
- input/cli
- testing/e2e
- containers
- tasks
- black_box
- container
- virtual_machine
- templates
- ansible
- docker-compose
- tracker
- tests
- e2e
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
194 files changed
+12090
-2588
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 14 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
Lines changed: 22 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
| 91 | + | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
| 121 | + | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
3 | 11 | | |
4 | 12 | | |
5 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
138 | 143 | | |
139 | 144 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
171 | | - | |
| 171 | + | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
175 | | - | |
| 175 | + | |
| 176 | + | |
176 | 177 | | |
177 | 178 | | |
178 | | - | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
193 | | - | |
| 194 | + | |
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
198 | | - | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | | - | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| |||
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
223 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
224 | 232 | | |
225 | 233 | | |
226 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
0 commit comments