This Rust application provides automated deployment infrastructure for Torrust tracker projects. It manages VM provisioning and cloud-init execution using LXD containers, with the goal of finding the best solution for creating VMs that support cloud-init both locally (development) and in CI environments (GitHub Actions).
- โ Create VMs supporting cloud-init locally and in GitHub runners
- โ Test cloud-init execution and verification
- โ Support Docker Compose inside VMs (planned)
- โ Fast, easy to install and use solutions
- โ No nested virtualization dependency (CI compatibility)
This repository uses LXD containers for virtualization:
- Technology: System containers with cloud-init support
- Status: โ Official provider - Guaranteed GitHub Actions compatibility
- Best for: CI/CD environments, fast provisioning, local development
- Requirements: No special virtualization needed
๐ See detailed documentation โ
๐ See detailed comparison โ
Feature | LXD (Official) | Multipass (Experimental) |
---|---|---|
GitHub Actions Support | โ Guaranteed | |
Nested Virtualization | โ Not needed | โ Required |
Boot Time | โ ~5-10s | โ ~30-60s |
Resource Usage | โ Lower | โ Higher |
Isolation Level | ๐ถ Process-level | โ Hardware-level |
This is a Rust application that automates deployment infrastructure using OpenTofu and Ansible.
Install the required tools:
# Check installations
lxd version && tofu version && ansible --version && cargo --version
Missing tools? See detailed installation guides:
Quick 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
The main application provides usage instructions:
# Build and run the application
cargo run
# Or install and run directly
cargo install --path .
torrust-tracker-deploy
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 clippy # Rust code analysis
cargo run --bin linter rustfmt # Rust formatting check
cargo run --bin linter shellcheck # Shell script linting
๐ See linting documentation โ
Use the E2E tests binary to run automated infrastructure tests:
# Run the comprehensive E2E tests
cargo run --bin e2e-tests-full
# Keep the test environment after completion
cargo run --bin e2e-tests-full -- --keep
# Use custom templates directory
cargo run --bin e2e-tests-full -- --templates-dir ./custom/templates
# See all available options
cargo run --bin e2e-tests-full -- --help
If you prefer manual deployment instead of using the E2E tests:
# Navigate to LXD configuration
cd templates/tofu/lxd
# Initialize and deploy
tofu init && tofu apply
# Navigate to Ansible configuration
cd ../../ansible
# Update inventory.yml with the VM's IP from step 1
# Then run the verification playbook
ansible-playbook wait-cloud-init.yml
# Install Docker on the VM
ansible-playbook install-docker.yml
# Install Docker Compose on the VM (optional)
ansible-playbook install-docker-compose.yml
lxc list torrust-tracker-vm
# Access the container directly
lxc exec torrust-tracker-vm -- /bin/bash
# Test SSH connection
ssh -i ~/.ssh/testing_rsa torrust@<VM_IP>
# Verify Docker installation
lxc exec torrust-vm -- docker --version
lxc exec torrust-vm -- docker run --rm hello-world
# Verify Docker Compose installation (if installed)
lxc exec torrust-vm -- docker-compose --version
- Provision: OpenTofu creates and configures VMs with cloud-init
- Configure: Ansible connects to VMs and executes management tasks
- 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 โ
The repository includes comprehensive GitHub Actions workflows for CI testing:
.github/workflows/test-e2e.yml
- End-to-End Tests - Runs automated E2E tests using the Rust binary.github/workflows/test-lxd-provision.yml
- Tests LXD container provisioning
- LXD container provisioning (local + GitHub Actions)
- Cloud-init support for LXD containers
- OpenTofu infrastructure as code
- Ansible configuration management setup
- Basic cloud-init verification playbook
- Docker installation playbook
- Docker Compose installation playbook
- Automated testing workflows
- End-to-End (E2E) deployment infrastructure and workflows
- Extended Ansible playbooks for application deployment
- Performance benchmarking
- Official GitHub Actions nested virtualization clarification
- Additional VM providers evaluation
- Integration with Torrust application testing
- Multi-architecture support (ARM64)
โโโ .github/ # CI/CD workflows and GitHub configuration
โ โโโ workflows/ # GitHub Actions workflow files
โโโ .vscode/ # VS Code workspace configuration
โโโ build/ # ๐ Generated runtime configs (git-ignored)
โ โโโ tofu/ # ๐๏ธ Runtime OpenTofu configs
โ โโโ ansible/ # ๐ค Runtime Ansible configs
โโโ data/ # Data files and templates
โ โโโ templates/ # Template sources for generation
โ โโโ ansible/ # Ansible template sources
โ โโโ tofu/ # OpenTofu template sources
โโโ docs/ # ๐ Detailed documentation
โ โโโ tech-stack/ # Technology-specific documentation
โ โ โโโ opentofu.md # OpenTofu installation and usage
โ โ โโโ ansible.md # Ansible installation and usage
โ โ โโโ lxd.md # LXD system containers
โ โโโ 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
โ โ โโโ testing.md # Testing conventions
โ โโโ research/ # Research and analysis documents
โ โโโ *.md # Various documentation files
โโโ examples/ # Example configurations and usage
โโโ fixtures/ # Test fixtures and sample data
โ โโโ testing_rsa* # SSH key pair for testing
โ โโโ tofu/ # OpenTofu test fixtures
โโโ packages/ # Rust workspace packages
โ โโโ 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
โ โโโ main.rs # Main application binary entry point
โ โโโ lib.rs # Library root module
โ โโโ bin/ # Binary executables
โ โ โโโ linter.rs # Unified linting command interface
โ โ โโโ e2e_tests.rs # End-to-end testing binary
โ โโโ ansible/ # Ansible integration modules
โ โโโ command_wrappers/ # External command wrapper modules
โ โโโ commands/ # CLI command implementations
โ โโโ config/ # Configuration handling
โ โโโ e2e/ # End-to-end testing infrastructure
โ โโโ remote_actions/ # Remote system management actions
โ โโโ steps/ # Deployment step implementations
โ โโโ template/ # Template processing and rendering
โ โโโ tofu/ # OpenTofu integration modules
โโโ templates/ # ๐ Template configurations (git-tracked)
โ โโโ tofu/ # ๐๏ธ OpenTofu/Terraform templates
โ โ โโโ lxd/ # LXD container 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
โโโ .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
- ๐ค Contributing Guide - Git workflow, commit process, and linting conventions
- ๐ Documentation Organization Guide - How documentation is organized and where to contribute
- ๐ Structured Logging Implementation Plan - Implementation plan for hierarchical logging with tracing spans
- ๐ OpenTofu Setup Guide - Installation, common commands, and best practices
- ๐ Ansible Setup Guide - Installation, configuration, and project usage
- ๐ VM Providers Comparison - Detailed comparison and decision rationale
This is a basic setup. Future enhancements could include:
- Multiple VMs for different testing scenarios
- Custom images with pre-installed Torrust components
- Network configuration for multi-VM setups
- Enhanced CI/CD integration with nested virtualization
- Automated testing scripts for Torrust applications