@@ -20,8 +20,9 @@ This project implements a **four-step deployment workflow** aligned with twelve-
2020
2121Create environment-specific configuration from templates:
2222
23- - ** Local Development** : ` infrastructure/config/environments/local.env.tpl ` → ` local.env `
24- - ** Production** : ` infrastructure/config/environments/production.env.tpl ` → ` production.env `
23+ - ** Development Environment** : ` development-libvirt.env ` (default) or custom name like ` my-dev.env `
24+ - ** End-to-end Testing** : ` e2e-libvirt.env ` (default) or custom name like ` ci-test.env `
25+ - ** Production Environment** : ` production-hetzner.env ` (default) or custom name like ` prod.env `
2526
2627The environment file contains ** all deployment configuration** , including:
2728
@@ -66,8 +67,37 @@ Verify deployment health and functionality:
6667- ** OpenTofu** (or Terraform) installed
6768- ** Git** for repository access
6869- ** SSH client** for server access
70+ - ** SSH key pair** for VM access (see SSH Key Configuration below)
6971- ** Domain name** (required for HTTPS certificates in production)
7072
73+ #### SSH Key Configuration
74+
75+ The deployment system requires an SSH public key for secure VM access. The system
76+ automatically detects SSH keys from these locations (in order):
77+
78+ 1 . ` ~/.ssh/torrust_rsa.pub ` (recommended - dedicated key for Torrust deployments)
79+ 2 . ` ~/.ssh/id_rsa.pub ` (common default SSH key)
80+ 3 . ` ~/.ssh/id_ed25519.pub ` (Ed25519 SSH key)
81+ 4 . ` ~/.ssh/id_ecdsa.pub ` (ECDSA SSH key)
82+
83+ ** Recommended Setup** :
84+
85+ ``` bash
86+ # Generate dedicated SSH key for Torrust deployments
87+ ssh-keygen -t rsa -b 4096 -f
~ /.ssh/torrust_rsa -C
" [email protected] " 88+
89+ # The public key (~/.ssh/torrust_rsa.pub) will be auto-detected
90+ # The private key (~/.ssh/torrust_rsa) will be used for SSH connections
91+ ```
92+
93+ ** Alternative Options** :
94+
95+ - ** Use existing key** : Copy your existing public key to ` ~/.ssh/torrust_rsa.pub `
96+ - ** Manual configuration** : Set ` SSH_PUBLIC_KEY ` in your environment file
97+ - ** Environment variable** : Export the key content as an environment variable
98+
99+ If no SSH key is found, the deployment will provide detailed error messages with setup instructions.
100+
71101### Cloud Provider Requirements (For Future Implementation)
72102
73103When cloud providers are implemented, they will need:
@@ -90,10 +120,18 @@ cloud-agnostic to facilitate adding cloud providers that support cloud-init in t
90120
91121## Quick Start
92122
93- ### Current Implementation: Local Development
123+ ### Current Implementation: Development Environment (KVM/libvirt)
94124
95- The current implementation supports local KVM/libvirt deployment, which is perfect
96- for development, testing, and understanding the system before cloud deployment.
125+ The current implementation supports local KVM/libvirt deployment using the ** development**
126+ environment type, which is perfect for development, testing, and understanding the system
127+ before cloud deployment.
128+
129+ ** Environment Types vs Environment Files** :
130+
131+ - ** Environment Types** : ` development ` , ` testing ` , ` e2e ` , ` staging ` , ` production `
132+ - ** Environment Files** : Any name you choose (e.g., ` my-dev.env ` , ` local-test.env ` )
133+ - ** Default Format** : ` {environment-type}-{provider}.env ` (when using generation scripts)
134+ - ** Examples** : ` development-libvirt.env ` , ` production-hetzner.env ` , ` my-custom-setup.env `
97135
98136### 1. Clone and Setup
99137
@@ -105,22 +143,29 @@ cd torrust-tracker-demo
105143# Install dependencies (Ubuntu/Debian)
106144make install-deps
107145
108- # Configure SSH access for VMs
109- make infra-config-local
146+ # Setup SSH key for VM access (if you don't have ~/.ssh/torrust_rsa.pub)
147+ ssh-keygen -t rsa -b 4096 -f
~ /.ssh/torrust_rsa -C
" [email protected] " 148+
149+ # The system will auto-detect ~/.ssh/torrust_rsa.pub during deployment
110150```
111151
112152### 2. Local Testing with KVM/libvirt
113153
114154``` bash
115- # Test deployment locally with KVM
155+ # Test deployment locally with KVM using development environment (default naming)
116156# Commands wait for full readiness by default
117- make infra-apply ENVIRONMENT=local
118- make app-deploy ENVIRONMENT=local
157+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
158+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
159+ make app-health-check
160+
161+ # Alternative: Use custom file names
162+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=my-custom-dev
163+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=my-custom-dev
119164make app-health-check
120165
121166# Advanced users: Skip waiting for faster execution
122- make infra-apply ENVIRONMENT=local SKIP_WAIT=true
123- make app-deploy ENVIRONMENT=local SKIP_WAIT=true
167+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
168+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
124169make app-health-check
125170
126171# Access the local instance via SSH
@@ -134,17 +179,20 @@ make vm-ssh
134179make infra-destroy
135180```
136181
182+ ** Note** : ` ENVIRONMENT_FILE ` can be any filename (without ` .env ` extension).
183+ The system looks for the file in ` infrastructure/config/environments/{filename}.env ` .
184+
137185### 3. Cloud Deployment (Planned - Hetzner)
138186
139187** Note** : Cloud deployment is not yet implemented. The following commands show the
140188planned interface for future Hetzner Cloud deployment:
141189
142190``` bash
143- # Planned: Deploy infrastructure to Hetzner Cloud
144- make infra-apply ENVIRONMENT =production PROVIDER= hetzner
191+ # Planned: Deploy infrastructure to Hetzner Cloud using production environment
192+ make infra-apply ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production- hetzner
145193
146194# Planned: Deploy application services
147- make app-deploy ENVIRONMENT =production
195+ make app-deploy ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
148196
149197# Validate deployment
150198make app-health-check
@@ -315,9 +363,14 @@ default, providing a much better user experience:
315363
316364``` bash
317365# Each command waits for full readiness by default
318- make infra-apply ENVIRONMENT=local # Waits for VM IP + cloud-init completion
319- make app-deploy ENVIRONMENT=local # Waits for all services to be healthy
320- make app-health-check # Validates everything is working
366+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
367+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
368+ make app-health-check
369+
370+ # What each command does:
371+ # infra-apply: Waits for VM IP + cloud-init completion
372+ # app-deploy: Waits for all services to be healthy
373+ # health-check: Validates everything is working
321374```
322375
323376** Key improvements** :
@@ -331,17 +384,17 @@ make app-health-check # Validates everything is working
331384
332385``` bash
333386# Skip waiting for faster execution (original behavior)
334- make infra-apply ENVIRONMENT=local SKIP_WAIT=true
335- make app-deploy ENVIRONMENT=local SKIP_WAIT=true
387+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
388+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
336389```
337390
338391### Infrastructure Deployment
339392
340393The infrastructure deployment creates and configures the VM:
341394
342395``` bash
343- # Deploy infrastructure
344- make infra-apply ENVIRONMENT=production
396+ # Deploy infrastructure using development environment
397+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
345398
346399# What this does:
347400# 1. Creates VM with Ubuntu 24.04
@@ -359,8 +412,8 @@ make infra-apply ENVIRONMENT=production
359412The application deployment sets up all services:
360413
361414``` bash
362- # Deploy application
363- make app-deploy ENVIRONMENT=production
415+ # Deploy application using development environment
416+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
364417
365418# What this does:
366419# 1. Clones torrust-tracker-demo repository
@@ -478,18 +531,18 @@ docker compose exec -T mysql mysql -u root -p torrust_tracker
478531
479532## Environment Configuration
480533
481- ### Local Development
534+ ### Development Environment ( Local Testing)
482535
483- For local testing and development:
536+ For local testing and development using KVM/libvirt :
484537
485538``` bash
486- # Use local environment
487- make infra-apply ENVIRONMENT=local
488- make app-deploy ENVIRONMENT=local
539+ # Use development environment type with libvirt provider
540+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
541+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
489542
490543# Features enabled:
491544# - HTTPS with self-signed certificates (automatic)
492- # - Local domain names (tracker.test.local, grafana. test.local)
545+ # - Local domain names (test.local)
493546# - Full monitoring with Grafana and Prometheus
494547# - MySQL database (same as production)
495548# - All production features except trusted SSL certificates
@@ -535,10 +588,10 @@ Generate the production configuration template:
535588
536589``` bash
537590# Generate production configuration template with placeholders
538- make infra-config-production
591+ make infra-config-production PROVIDER=hetzner
539592```
540593
541- This will create ` infrastructure/config/environments/production.env ` with secure placeholder
594+ This will create ` infrastructure/config/environments/production-hetzner .env ` with secure placeholder
542595values that need to be replaced with your actual configuration.
543596
544597#### Step 3: Replace Placeholder Values
@@ -547,7 +600,7 @@ Edit the generated production environment file with your secure secrets and doma
547600
548601``` bash
549602# Edit the production configuration
550- vim infrastructure/config/environments/production.env
603+ vim infrastructure/config/environments/production-hetzner .env
551604```
552605
553606** Replace these placeholder values with your actual configuration** :
@@ -594,9 +647,9 @@ make infra-config-production
594647planned interface for future production deployments:
595648
596649``` bash
597- # Planned: Use production environment
598- make infra-apply ENVIRONMENT =production DOMAIN=your-domain.com
599- make app-deploy ENVIRONMENT =production
650+ # Planned: Use production environment type with Hetzner provider
651+ make infra-apply ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
652+ make app-deploy ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
600653
601654# Planned features:
602655# - HTTPS support (with automated certificate setup)
0 commit comments