Skip to content

Deployment tool for Torrust Tracker - automated infrastructure provisioning and configuration with Rust, OpenTofu, and Ansible

License

Notifications You must be signed in to change notification settings

torrust/torrust-tracker-deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Linting Testing E2E Infrastructure Tests E2E Deployment Tests Test LXD Container Provisioning Coverage

Torrust Tracker Deployer

โš ๏ธ DEVELOPMENT STATUS: Early Production Phase

This project is in active development with initial cloud provider support now available.

Current Scope:

  • โœ… Local LXD virtual machine provisioning
  • โœ… Hetzner Cloud support for production deployments
  • โœ… Development and testing workflows
  • โœ… Multi-provider architecture (provider selection via configuration)
  • โœ… Application deployment (Torrust Tracker stack with Docker Compose)

๐Ÿ“‹ MVP Goal: After completing the roadmap, we will have a fully automated deployment solution for Torrust Tracker with complete application stack management and multi-cloud provider support.

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.

๐ŸŽฏ Project Goals

Current Development Phase:

  • โœ… Create local VMs supporting cloud-init for development and CI testing
  • โœ… Test cloud-init execution and verification in controlled environments
  • โœ… Support Docker Compose inside VMs for application stacks
  • โœ… Fast, easy to install and use local development solution
  • โœ… No nested virtualization dependency (CI compatibility)
  • โœ… Multi-provider support (LXD for local, Hetzner Cloud for production)
  • โœ… Application stack deployment (Torrust Tracker with Docker Compose)

Future MVP Goals: (See roadmap)

  • ๐Ÿ”„ Additional cloud providers (AWS, GCP, Azure)
  • ๐Ÿ”„ Multi-environment management
  • ๐Ÿ”„ Enhanced observability (monitoring, alerting, metrics)

๐Ÿ”ง Local Development Approach

This repository uses LXD virtual machines for local virtualization and development:

โ˜๏ธ LXD Virtual Machines (templates/tofu/lxd/) - LOCAL DEVELOPMENT

  • Technology: Virtual machines with cloud-init support
  • Status: โœ… Production-ready for local development and CI testing
  • Best for: Local development, CI/CD environments, fast iteration
  • Requirements: No special virtualization needed

๐Ÿ“– See detailed documentation โ†’

๐Ÿ“Š LXD Benefits

๐Ÿ“– See detailed comparison โ†’

Feature LXD Virtual Machines
GitHub Actions Support โœ… Guaranteed
Nested Virtualization โŒ Not needed
Boot Time โœ… Fast (~5-10s)
Resource Usage โœ… Efficient
Installation โœ… Simple setup

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

This is a Rust application that automates deployment infrastructure using OpenTofu and Ansible.

Automated Setup (Recommended)

The project provides a dependency installer tool that automatically detects and installs required dependencies:

# Install all required dependencies
cargo run --bin dependency-installer install

# Check which dependencies are installed
cargo run --bin dependency-installer check

# List all dependencies with status
cargo run --bin dependency-installer list

The installer supports: OpenTofu, Ansible, LXD, and cargo-machete.

For detailed information, see ๐Ÿ“– Dependency Installer โ†’.

Manual Setup

If you prefer manual installation or need to troubleshoot:

Check installations:

lxd version && tofu version && ansible --version && cargo --version

Missing tools? See detailed installation guides:

Quick manual install:

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install LXD
sudo snap install lxd && sudo lxd init --auto && sudo usermod -a -G lxd $USER && newgrp lxd

# Install OpenTofu
curl -fsSL https://get.opentofu.org/install-opentofu.sh | sudo bash

# Install Ansible
sudo apt install ansible

๐Ÿ’ป Usage

๐Ÿš€ Main Application

The main application provides usage instructions:

# Build and run the application
cargo run

# Or install and run directly
cargo install --path .
torrust-tracker-deployer

For detailed usage instructions, command reference, and examples, see the ๐Ÿ‘ค User Guide.

The application includes comprehensive logging with configurable format, output mode, and directory. See ๐Ÿ“– Logging Guide for details on logging configuration options.

๐Ÿ”ง Development Tasks

This project includes convenient scripts for common development tasks:

# Run all linters (markdown, YAML, TOML, shell scripts, Rust)
cargo run --bin linter all

Or run individual linters:

cargo run --bin linter markdown    # Markdown linting
cargo run --bin linter yaml        # YAML linting
cargo run --bin linter toml        # TOML linting
cargo run --bin linter cspell      # Spell checking
cargo run --bin linter clippy      # Rust code analysis
cargo run --bin linter rustfmt     # Rust formatting check
cargo run --bin linter shellcheck  # Shell script linting

๐Ÿ“– See linting documentation โ†’

๐Ÿงช Running E2E Tests

Use the E2E test binaries to run automated infrastructure tests with hardcoded environments:

# Run comprehensive E2E tests (LOCAL ONLY - connectivity issues in GitHub runners)
cargo run --bin e2e-complete-workflow-tests

# Run individual E2E test suites
cargo run --bin e2e-deployment-workflow-tests         # Configuration, release, and run workflow tests
cargo run --bin e2e-infrastructure-lifecycle-tests   # Infrastructure provisioning tests

# Keep the test environment after completion for inspection
cargo run --bin e2e-complete-workflow-tests -- --keep
cargo run --bin e2e-infrastructure-lifecycle-tests -- --keep

# Use custom templates directory
cargo run --bin e2e-complete-workflow-tests -- --templates-dir ./custom/templates

# See all available options
cargo run --bin e2e-complete-workflow-tests -- --help

โš ๏ธ Important Notes:

  • E2E tests create hardcoded environments with predefined configurations
  • Use --keep flag to inspect generated data/ and build/ directories after tests
  • e2e-complete-workflow-tests can only run locally due to connectivity issues in GitHub runners
  • To see final OpenTofu and Ansible templates, check build/ directories after running with --keep

๐Ÿ“– Manual Deployment Steps

โœ… Complete deployment workflow is now available! You can create, provision, configure, test, deploy, run, and destroy Torrust Tracker environments using the CLI.

Current Status:

  • โœ… Environment Management: Create and manage deployment environments
  • โœ… Infrastructure Provisioning: Provision VM infrastructure with LXD or Hetzner Cloud
  • โœ… Configuration: Configure provisioned infrastructure (Docker, Docker Compose)
  • โœ… Verification: Test deployment infrastructure
  • โœ… Application Deployment: Deploy Torrust Tracker configuration and database
  • โœ… Service Management: Start and manage tracker services

Available Commands:

# 1. Generate configuration template
torrust-tracker-deployer create template my-env.json

# 2. Edit my-env.json with your settings

# 3. Create environment from configuration
torrust-tracker-deployer create environment -f my-env.json

# 4. Provision VM infrastructure
torrust-tracker-deployer provision my-environment

# 5. Configure infrastructure (install Docker, Docker Compose)
torrust-tracker-deployer configure my-environment

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

# 7. Deploy tracker application configuration
torrust-tracker-deployer release my-environment

# 8. Start tracker services
torrust-tracker-deployer run my-environment

# 9. Destroy environment when done
torrust-tracker-deployer destroy my-environment

๐Ÿ“– For detailed command documentation and guides, see:

๐ŸŽญ Infrastructure Workflow

  1. Provision: OpenTofu creates and configures VMs with cloud-init
  2. Configure: Ansible connects to VMs and executes management tasks
  3. Verify: Automated checks ensure proper setup and functionality
Phase Tool Purpose
Infrastructure OpenTofu VM provisioning and cloud-init setup
Configuration Ansible Task execution and configuration management
Verification Ansible Playbooks System checks and validation

๐Ÿ“– See detailed Ansible documentation โ†’

๐Ÿงช Testing in GitHub Actions

The repository includes comprehensive GitHub Actions workflows for CI testing:

  • .github/workflows/linting.yml - Code Quality - Runs all linters (markdown, YAML, TOML, Rust, shell scripts)
  • .github/workflows/testing.yml - Unit Tests - Runs Rust unit tests and basic validation
  • .github/workflows/test-e2e-infrastructure.yml - E2E Infrastructure Tests - Tests infrastructure provisioning and destruction
  • .github/workflows/test-e2e-deployment.yml - E2E Deployment Tests - Tests software installation, configuration, release, and run workflows
  • .github/workflows/test-lxd-provision.yml - LXD Provisioning - Tests LXD VM provisioning specifically

Note: The complete E2E workflow tests (e2e-complete-workflow-tests) can only be executed locally due to connectivity issues documented in docs/e2e-testing/.

๐Ÿ—บ๏ธ Roadmap

This project follows a structured development roadmap to evolve from the current local development focus to a production-ready deployment solution.

Current Development Status:

  • โœ… Local LXD Infrastructure: VM provisioning, cloud-init, E2E testing
  • โœ… Development Workflows: Linting, testing, CI/CD automation
  • โœ… Foundation Layer: OpenTofu + Ansible + Docker integration

Next Major Milestones:

  • ๐Ÿ”„ Main Application Commands: create, deploy, destroy, status
  • ๏ฟฝ Real Cloud Providers: Starting with Hetzner, expanding to AWS/GCP/Azure
  • ๐Ÿ”„ Production Features: HTTPS, backups, monitoring stack

๐Ÿ“– See complete roadmap โ†’

๐Ÿ“ Repository Structure

โ”œโ”€โ”€ .github/                       # CI/CD workflows and GitHub configuration
โ”‚   โ””โ”€โ”€ workflows/                 # GitHub Actions workflow files
โ”œโ”€โ”€ build/                         # ๐Ÿ“ Generated runtime configs (git-ignored)
โ”‚   โ”œโ”€โ”€ e2e-complete/              # E2E complete workflow test runtime files
โ”‚   โ”œโ”€โ”€ e2e-deployment/            # E2E deployment test runtime files
โ”‚   โ”œโ”€โ”€ e2e-infrastructure/        # E2E infrastructure test runtime files
โ”‚   โ””โ”€โ”€ manual-test-*/             # Manual test environment runtime files
โ”œโ”€โ”€ data/                          # Environment-specific data and configurations
โ”‚   โ”œโ”€โ”€ e2e-complete/              # E2E complete workflow test environment data
โ”‚   โ”œโ”€โ”€ e2e-deployment/            # E2E deployment test environment data
โ”‚   โ”œโ”€โ”€ e2e-infrastructure/        # E2E infrastructure test environment data
โ”‚   โ”œโ”€โ”€ manual-test-*/             # Manual test environment data
โ”‚   โ””โ”€โ”€ logs/                      # Application logs
โ”œโ”€โ”€ docker/                        # Docker-related configurations
โ”‚   โ””โ”€โ”€ provisioned-instance/      # Docker setup for provisioned instances
โ”œโ”€โ”€ docs/                          # ๐Ÿ“– Detailed documentation
โ”‚   โ”œโ”€โ”€ tech-stack/                # Technology-specific documentation
โ”‚   โ”‚   โ”œโ”€โ”€ opentofu.md            # OpenTofu installation and usage
โ”‚   โ”‚   โ”œโ”€โ”€ ansible.md             # Ansible installation and usage
โ”‚   โ”‚   โ””โ”€โ”€ lxd.md                 # LXD virtual machines
โ”‚   โ”œโ”€โ”€ user-guide/                # User documentation
โ”‚   โ”‚   โ”œโ”€โ”€ commands/              # Command reference documentation
โ”‚   โ”‚   โ””โ”€โ”€ providers/             # Provider-specific guides (LXD, Hetzner)
โ”‚   โ”œโ”€โ”€ decisions/                 # Architecture Decision Records (ADRs)
โ”‚   โ”œโ”€โ”€ contributing/              # Contributing guidelines and conventions
โ”‚   โ”‚   โ”œโ”€โ”€ README.md              # Main contributing guide
โ”‚   โ”‚   โ”œโ”€โ”€ branching.md           # Git branching conventions
โ”‚   โ”‚   โ”œโ”€โ”€ commit-process.md      # Commit process and pre-commit checks
โ”‚   โ”‚   โ”œโ”€โ”€ error-handling.md      # Error handling principles
โ”‚   โ”‚   โ”œโ”€โ”€ module-organization.md # Module organization conventions
โ”‚   โ”‚   โ””โ”€โ”€ testing/               # Testing conventions and guides
โ”‚   โ”œโ”€โ”€ features/                  # Feature specifications and documentation
โ”‚   โ”œโ”€โ”€ research/                  # Research and analysis documents
โ”‚   โ””โ”€โ”€ *.md                       # Various documentation files
โ”œโ”€โ”€ envs/                          # ๐Ÿ“ User environment configurations (git-ignored)
โ”‚   โ””โ”€โ”€ *.json                     # Environment configuration files for CLI
โ”œโ”€โ”€ fixtures/                      # Test fixtures and sample data
โ”‚   โ”œโ”€โ”€ testing_rsa*               # SSH key pair for testing
โ”‚   โ””โ”€โ”€ tofu/                      # OpenTofu test fixtures
โ”œโ”€โ”€ packages/                      # Rust workspace packages
โ”‚   โ”œโ”€โ”€ dependency-installer/      # Dependency detection and installation
โ”‚   โ””โ”€โ”€ linting/                   # Linting utilities package
โ”‚       โ””โ”€โ”€ src/                   # Linting implementation source code
โ”œโ”€โ”€ scripts/                       # Development and utility scripts
โ”‚   โ””โ”€โ”€ setup/                     # Installation scripts for dependencies
โ”œโ”€โ”€ src/                           # ๐Ÿฆ€ Main Rust application source code (DDD Architecture)
โ”‚   โ”œโ”€โ”€ main.rs                    # Main application binary entry point
โ”‚   โ”œโ”€โ”€ lib.rs                     # Library root module
โ”‚   โ”œโ”€โ”€ container.rs               # Dependency injection container
โ”‚   โ”œโ”€โ”€ logging.rs                 # Logging configuration
โ”‚   โ”œโ”€โ”€ bin/                       # Binary executables
โ”‚   โ”‚   โ”œโ”€โ”€ linter.rs              # Unified linting command interface
โ”‚   โ”‚   โ””โ”€โ”€ e2e*.rs                # End-to-end testing binaries
โ”‚   โ”œโ”€โ”€ application/               # Application layer (use cases, commands)
โ”‚   โ”œโ”€โ”€ domain/                    # Domain layer (business logic, entities)
โ”‚   โ”‚   โ””โ”€โ”€ provider/              # Provider types (LXD, Hetzner)
โ”‚   โ”œโ”€โ”€ infrastructure/            # Infrastructure layer (external systems)
โ”‚   โ”œโ”€โ”€ presentation/              # Presentation layer (CLI interface)
โ”‚   โ”œโ”€โ”€ adapters/                  # External tool adapters (OpenTofu, Ansible, SSH, LXD)
โ”‚   โ”œโ”€โ”€ shared/                    # Shared utilities and common code
โ”‚   โ”œโ”€โ”€ testing/                   # Testing utilities and mocks
โ”‚   โ”œโ”€โ”€ config/                    # Configuration handling
โ”‚   โ”œโ”€โ”€ bootstrap/                 # Application bootstrapping
โ”‚   โ””โ”€โ”€ e2e/                       # End-to-end testing infrastructure
โ”œโ”€โ”€ templates/                     # ๐Ÿ“ Template configurations (git-tracked)
โ”‚   โ”œโ”€โ”€ tofu/                      # ๐Ÿ—๏ธ OpenTofu/Terraform templates
โ”‚   โ”‚   โ”œโ”€โ”€ lxd/                   # LXD VM template configuration
โ”‚   โ”‚   โ””โ”€โ”€ hetzner/               # Hetzner Cloud template configuration
โ”‚   โ””โ”€โ”€ ansible/                   # ๐Ÿค– Ansible playbook templates
โ”œโ”€โ”€ tests/                         # Integration and system tests
โ”œโ”€โ”€ target/                        # ๐Ÿฆ€ Rust build artifacts (git-ignored)
โ”œโ”€โ”€ Cargo.toml                     # Rust workspace configuration
โ”œโ”€โ”€ Cargo.lock                     # Rust dependency lock file
โ”œโ”€โ”€ cspell.json                    # Spell checking configuration
โ”œโ”€โ”€ project-words.txt              # Custom dictionary for spell checking
โ”œโ”€โ”€ .markdownlint.json             # Markdown linting configuration
โ”œโ”€โ”€ .prettierignore                # Prettier ignore rules (for Tera templates)
โ”œโ”€โ”€ .taplo.toml                    # TOML formatting configuration
โ”œโ”€โ”€ .yamllint-ci.yml               # YAML linting configuration for CI
โ”œโ”€โ”€ README.md                      # This file - project overview
โ”œโ”€โ”€ LICENSE                        # Project license
โ””โ”€โ”€ .gitignore                     # Git ignore rules

๐Ÿ“š Documentation

๐Ÿ”ฎ Next Steps

This project now supports multiple infrastructure providers. The path to production-ready deployment is outlined in our ๐Ÿ“‹ Roadmap.

Recent achievements:

  • โœ… Multi-Provider Support: LXD for local development, Hetzner Cloud for production deployments
  • โœ… Provider Selection: Choose your provider via provider_config in environment configuration
  • โœ… Complete CLI Commands: create, provision, configure, test, and destroy commands

Key upcoming milestones:

  • Application Stack Management: Complete Docker Compose stacks with Torrust Tracker, MySQL, Prometheus, and Grafana
  • HTTPS Support: SSL/TLS configuration for all services
  • Backup & Recovery: Database backups and disaster recovery procedures
  • Additional Cloud Providers: AWS, GCP, and Azure support

๐Ÿ“– See full roadmap โ†’

About

Deployment tool for Torrust Tracker - automated infrastructure provisioning and configuration with Rust, OpenTofu, and Ansible

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages