Skip to content

Commit 8f02c0b

Browse files
committed
refactor: rename VM instance from 'torrust-vm' to 'torrust-tracker-vm'
- Update Ansible inventory template with new instance name - Update all hardcoded references in Rust source code - Update test assertions and mock data - Update documentation and GitHub workflows - Update OpenTofu variable references in comments - Maintain backward compatibility while preparing for multiple Torrust application VMs All linters, unit tests, and core e2e functionality verified to work with the new naming.
1 parent c2b108d commit 8f02c0b

File tree

13 files changed

+80
-81
lines changed

13 files changed

+80
-81
lines changed

.github/workflows/test-e2e.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ jobs:
7474
sudo -E tofu output || echo "No outputs available"
7575
7676
echo "=== Container Status ==="
77-
sudo lxc list torrust-vm || echo "Container not found"
77+
sudo lxc list torrust-tracker-vm || echo "Container not found"
7878
79-
echo "=== Container Info ==="
80-
sudo lxc info torrust-vm || echo "Container info not available"
79+
# Check if the container has an IP address before proceeding
80+
sudo lxc info torrust-tracker-vm || echo "Container info not available"
8181
8282
- name: Debug information (on failure)
8383
if: failure()
@@ -104,7 +104,7 @@ jobs:
104104
# Use sudo for CI environment cleanup
105105
# NOTE: For local development, use "sg lxd -c 'tofu destroy'" instead
106106
sudo -E tofu destroy -auto-approve || echo "Destroy command failed or nothing to destroy"
107-
sudo lxc delete torrust-vm --force || echo "Container deletion failed or container doesn't exist"
107+
sudo lxc delete torrust-tracker-vm --force || echo "Container deletion failed or container doesn't exist"
108108
109109
- name: Final verification
110110
if: always()

.github/workflows/test-lxd-provision.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
timeout=300
110110
elapsed=0
111111
while [ $elapsed -lt $timeout ]; do
112-
if lxc exec torrust-vm -- test -f /tmp/provision_complete 2>/dev/null; then
112+
if lxc exec torrust-tracker-vm -- test -f /tmp/provision_complete 2>/dev/null; then
113113
echo "Container provisioning completed successfully!"
114114
break
115115
fi
@@ -127,35 +127,35 @@ jobs:
127127
run: |
128128
# Test basic connectivity
129129
lxc list
130-
lxc info torrust-vm
130+
lxc info torrust-tracker-vm
131131
132132
# Test command execution
133-
lxc exec torrust-vm -- whoami
133+
lxc exec torrust-tracker-vm -- whoami
134134
135135
# Test system information with error handling
136136
echo "Getting system information..."
137-
lxc exec torrust-vm -- cat /etc/os-release || echo "os-release failed"
137+
lxc exec torrust-tracker-vm -- cat /etc/os-release || echo "os-release failed"
138138
sleep 1
139139
140-
lxc exec torrust-vm -- df -h || echo "df failed"
140+
lxc exec torrust-tracker-vm -- df -h || echo "df failed"
141141
sleep 1
142142
143-
lxc exec torrust-vm -- free -h || echo "free failed"
143+
lxc exec torrust-tracker-vm -- free -h || echo "free failed"
144144
sleep 1
145145
146146
# Test cloud-init functionality
147147
echo "Testing cloud-init..."
148-
lxc exec torrust-vm -- cloud-init status || echo "cloud-init status failed"
148+
lxc exec torrust-tracker-vm -- cloud-init status || echo "cloud-init status failed"
149149
sleep 1
150150
151151
# Test user creation
152152
echo "Testing user creation..."
153-
lxc exec torrust-vm -- id torrust || echo "torrust user not found"
153+
lxc exec torrust-tracker-vm -- id torrust || echo "torrust user not found"
154154
sleep 1
155155
156156
# Test systemd services
157157
echo "Testing systemd..."
158-
lxc exec torrust-vm -- systemctl status ssh || echo "ssh service check failed"
158+
lxc exec torrust-tracker-vm -- systemctl status ssh || echo "ssh service check failed"
159159
160160
- name: Get container outputs
161161
working-directory: build/tofu/lxd
@@ -169,7 +169,7 @@ jobs:
169169
# Use tofu without sudo since socket permissions are set up
170170
# NOTE: For local development, use "sg lxd -c 'tofu destroy'" instead
171171
tofu destroy -auto-approve || true
172-
lxc delete torrust-vm --force || true
172+
lxc delete torrust-tracker-vm --force || true
173173
174174
- name: Final verification
175175
if: always()

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ ansible-playbook install-docker-compose.yml
162162
#### 3. Verify Deployment
163163

164164
```bash
165-
# Check VM status
166-
lxc list torrust-vm
165+
lxc list torrust-tracker-vm
167166

168-
# Connect to VM
169-
lxc exec torrust-vm -- /bin/bash
167+
# Access the container directly
168+
lxc exec torrust-tracker-vm -- /bin/bash
170169

171170
# Test SSH connection
172171
ssh -i ~/.ssh/testing_rsa torrust@<VM_IP>

docs/e2e-testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ If tests fail and leave resources behind, you can manually clean up:
117117
lxc list
118118

119119
# Stop and delete the test container
120-
lxc stop torrust-vm
121-
lxc delete torrust-vm
120+
lxc stop torrust-tracker-vm
121+
lxc delete torrust-tracker-vm
122122

123123
# Or use OpenTofu to clean up
124124
cd build/tofu/lxd
@@ -164,7 +164,7 @@ Use the `--keep` flag to inspect the environment after test completion:
164164
cargo run --bin e2e-tests -- --keep
165165

166166
# After test completion, connect to the container:
167-
lxc exec torrust-vm -- /bin/bash
167+
lxc exec torrust-tracker-vm -- /bin/bash
168168
```
169169

170170
## 🏗️ Architecture

docs/refactors/instance-name-parameterization.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
This refactor aims to eliminate hardcoded "torrust-vm" instance names throughout the codebase and replace them with parameterized values. The goal is to enable dynamic instance naming for different environments and support running multiple instances simultaneously.
5+
This refactor aims to eliminate hardcoded "torrust-tracker-vm" instance names throughout the codebase and replace them with parameterized values. The goal is to enable dynamic instance naming for different environments and support running multiple instances simultaneously.
66

77
## 📊 Progress Status
88

@@ -45,7 +45,7 @@ This refactor aims to eliminate hardcoded "torrust-vm" instance names throughout
4545
All planned phases for instance name parameterization have been successfully implemented. The refactor is complete with the following achievements:
4646

4747
- **Instance names are now configurable** through the `Config` struct and E2E test environment
48-
- **Hardcoded "torrust-vm" values eliminated** from key infrastructure components
48+
- **Hardcoded "torrust-tracker-vm" values eliminated** from key infrastructure components
4949
- **Template system supports dynamic instance naming** via Tera templating
5050
- **E2E tests can use custom instance names** while maintaining backward compatibility
5151
- **All quality gates passed**: linters, unit tests, and e2e tests successful
@@ -71,7 +71,7 @@ All planned phases for instance name parameterization have been successfully imp
7171
- ✅ Create `templates/tofu/lxd/variables.tfvars` template file to define `instance_name` variable
7272
- ✅ Update `TofuTemplateRenderer` to include this file in static template copying
7373
- ✅ Keep `image` variable static (not templated)
74-
- **Status**: Static variables file created with hardcoded "torrust-vm" value
74+
- **Status**: Static variables file created with hardcoded "torrust-tracker-vm" value
7575
- **Validation**: ✅ Unit tests + linters + e2e tests passed
7676

7777
#### Step 1b: Update OpenTofu client for variables file ✅
@@ -112,9 +112,9 @@ All planned phases for instance name parameterization have been successfully imp
112112
- ✅ Created `render_variables_template()` method for dynamic rendering
113113
- ✅ Updated `render_tera_templates()` to call variables template rendering
114114
- ✅ Removed `variables.tfvars` from static template files list
115-
- ✅ Added hardcoded "torrust-vm" values for backward compatibility
115+
- ✅ Added hardcoded "torrust-tracker-vm" values for backward compatibility
116116
- ✅ Updated all test constructors to include `instance_name` parameter
117-
- **Status**: Variables template now dynamically renders with `instance_name = "torrust-vm"`
117+
- **Status**: Variables template now dynamically renders with `instance_name = "torrust-tracker-vm"`
118118
- **Validation**: ✅ All linters + unit tests + e2e tests passed
119119

120120
### Phase 3: Context Integration ✅
@@ -137,7 +137,7 @@ Instead of the originally planned `TofuContext` approach, we implemented instanc
137137
- ✅ Added `instance_name` parameter to `TestEnvironment::with_ssh_user()` in `src/e2e/environment.rs`
138138
- ✅ Updated `TestEnvironment::with_ssh_user_and_init()` to accept `instance_name` parameter
139139
- ✅ Updated `create_config()` helper function to accept `instance_name` parameter
140-
- ✅ Maintained backward compatibility with existing `new()` functions using hardcoded "torrust-vm"
140+
- ✅ Maintained backward compatibility with existing `new()` functions using hardcoded "torrust-tracker-vm"
141141
- **Status**: E2E test infrastructure can now create environments with custom instance names
142142
- **Validation**: ✅ All linters + unit tests + e2e tests passed
143143

@@ -147,7 +147,7 @@ Instead of the originally planned `TofuContext` approach, we implemented instanc
147147

148148
- ✅ Updated `TestEnvironment::new()` method in `src/e2e/environment.rs` to accept `instance_name: &str` parameter
149149
- ✅ Updated `TestEnvironment::new_and_init()` method to accept `instance_name` parameter
150-
- ✅ Added `instance_name` variable in `main()` function of `src/bin/e2e_tests.rs` with hardcoded "torrust-vm" value
150+
- ✅ Added `instance_name` variable in `main()` function of `src/bin/e2e_tests.rs` with hardcoded "torrust-tracker-vm" value
151151
- ✅ Updated method call to pass `instance_name` from main to `TestEnvironment::new()`
152152
- ✅ Added proper documentation with `# Panics` section for clippy compliance
153153
- ✅ Updated documentation example in `src/e2e/tasks/preflight_cleanup.rs` to use new signature
@@ -169,7 +169,7 @@ The implementation evolved from the original plan due to codebase changes:
169169

170170
### 🎯 Outcomes
171171

172-
- **Hardcoded Instances Eliminated**: Key hardcoded "torrust-vm" strings removed from infrastructure provisioning
172+
- **Hardcoded Instances Eliminated**: Key hardcoded "torrust-tracker-vm" strings removed from infrastructure provisioning
173173
- **Dynamic Instance Naming**: Instance names can now be configured at runtime through the Config struct
174174
- **Test Environment Flexibility**: E2E tests can create environments with custom instance names
175175
- **Configuration Centralization**: All instance name handling flows through the `Config` struct
@@ -187,14 +187,14 @@ The implementation evolved from the original plan due to codebase changes:
187187
**Results**:
188188

189189
- Instance names configurable through `Config` struct and E2E main function
190-
- All hardcoded "torrust-vm" references eliminated from core infrastructure
190+
- All hardcoded "torrust-tracker-vm" references eliminated from core infrastructure
191191
- All tests passing (linters, 259 unit tests, e2e deployment tests)
192192
- Zero unused dependencies
193193
- Full backward compatibility maintained
194194

195-
## 🔍 Analysis of Current "torrust-vm" Usage
195+
## 🔍 Analysis of Current "torrust-tracker-vm" Usage
196196

197-
Currently, the instance name "torrust-vm" is hardcoded in multiple places across the codebase, including:
197+
Currently, the instance name "torrust-tracker-vm" is hardcoded in multiple places across the codebase, including:
198198

199199
- Infrastructure configuration files (OpenTofu templates)
200200
- Rust code literals and variables
@@ -207,9 +207,9 @@ This creates several issues:
207207
- Hard to customize instance names for different environments
208208
- Tight coupling between configuration and implementation
209209

210-
## Summary of "torrust-vm" Usage Analysis
210+
## Summary of "torrust-tracker-vm" Usage Analysis
211211

212-
Based on a comprehensive search through the codebase, **61 occurrences** of "torrust-vm" were found across 4 main categories:
212+
Based on a comprehensive search through the codebase, **61 occurrences** of "torrust-tracker-vm" were found across 4 main categories:
213213

214214
### 1. Configuration Files (2 files, 7 occurrences)
215215

@@ -340,7 +340,7 @@ Start from low-level infrastructure details and work up to higher abstractions:
340340
## Success Criteria
341341

342342
- [ ] Instance name defined once in `src/bin/e2e_tests.rs`
343-
- [ ] All hardcoded "torrust-vm" references eliminated
343+
- [ ] All hardcoded "torrust-tracker-vm" references eliminated
344344
- [ ] OpenTofu uses variables file for parameterization
345345
- [ ] All tests (unit, linting, e2e) pass at each step
346346
- [ ] No regression in functionality

docs/tofu-lxd-configuration.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Before provisioning, you may want to customize:
162162

163163
1. **SSH Key**: Edit the `cloud-init.yml` file and replace the SSH key with your actual public key
164164
2. **Container Specifications**: Adjust resource limits in `main.tf`
165-
3. **Container Name**: Change the instance name from "torrust-vm" to your preferred name
165+
3. **Container Name**: Change the instance name from "torrust-tracker-vm" to your preferred name
166166
4. **Packages**: Modify the packages list in `cloud-init.yml` to include additional software
167167

168168
## Provisioning
@@ -210,7 +210,7 @@ To provision the container:
210210
instance_info = {
211211
"image" = "ubuntu:22.04"
212212
"ip_address" = "10.140.190.155"
213-
"name" = "torrust-vm"
213+
"name" = "torrust-tracker-vm"
214214
"status" = "Running"
215215
}
216216
```
@@ -223,81 +223,79 @@ To provision the container:
223223

224224
6. **Access the container**:
225225

226-
```bash
227-
# Direct shell access
228-
lxc exec torrust-vm -- /bin/bash
229-
230-
# If you have LXD permission issues, use:
231-
sg lxd -c "lxc exec torrust-vm -- /bin/bash"
226+
````bash
227+
# Direct shell access
228+
lxc exec torrust-tracker-vm -- /bin/bash
232229

233-
# SSH access (if you configured your SSH key and networking)
234-
ssh torrust@<container-ip-address>
235-
```
230+
# Or if you need to use the lxd group:
231+
sg lxd -c "lxc exec torrust-tracker-vm -- /bin/bash"
236232

237-
## Managing the Container
233+
# SSH access (if you configured your SSH key and networking)
234+
ssh torrust@<container-ip-address>
235+
```## Managing the Container
238236
239-
After provisioning, you can manage the `torrust-vm` container using standard LXD commands:
237+
After provisioning, you can manage the `torrust-tracker-vm` container using standard LXD commands:
240238
241239
### Access the Container
242240
243241
```bash
244242
# Direct shell access
245-
lxc exec torrust-vm -- /bin/bash
243+
lxc exec torrust-tracker-vm -- /bin/bash
246244

247-
# If you have LXD permission issues, use:
248-
sg lxd -c "lxc exec torrust-vm -- /bin/bash"
245+
# Or if you need to use the lxd group:
246+
sg lxd -c "lxc exec torrust-tracker-vm -- /bin/bash"
249247

250248
# SSH access (if you configured your SSH key and networking)
251249
ssh torrust@<container-ip-address>
252-
```
250+
````
253251

254252
### Check Container Status
255253

256254
```bash
257255
# Check the status of our specific container
258-
lxc info torrust-vm
256+
lxc info torrust-tracker-vm
259257

260-
# List all containers (including torrust-vm)
258+
# List all containers (including torrust-tracker-vm)
261259
lxc list
262260
```
263261

264262
### Container Lifecycle
265263

266264
```bash
267265
# Stop the container
268-
lxc stop torrust-vm
266+
lxc stop torrust-tracker-vm
269267

270268
# Start the container
271-
lxc start torrust-vm
269+
lxc start torrust-tracker-vm
272270

273271
# Restart the container
274-
lxc restart torrust-vm
272+
lxc restart torrust-tracker-vm
275273
```
276274

277275
### Common Operations
278276

279277
```bash
280278
# Check if cloud-init provisioning completed
281-
lxc exec torrust-vm -- cat /tmp/provision_complete
279+
lxc exec torrust-tracker-vm -- cat /tmp/provision_complete
282280

283281
# Check system information
284-
lxc exec torrust-vm -- lsb_release -a
282+
lxc exec torrust-tracker-vm -- lsb_release -a
285283

286284
# Check systemd services (works in LXD system containers!)
287-
lxc exec torrust-vm -- systemctl status ssh
285+
lxc exec torrust-tracker-vm -- systemctl status ssh
288286

289287
# Install additional packages (if needed during development)
290-
lxc exec torrust-vm -- sudo apt update
291-
lxc exec torrust-vm -- sudo apt install -y git curl wget htop vim
288+
lxc exec torrust-tracker-vm -- sudo apt update
289+
lxc exec torrust-tracker-vm -- sudo apt install -y git curl wget htop vim
292290

293291
# Check available disk space
294-
lxc exec torrust-vm -- df -h
292+
lxc exec torrust-tracker-vm -- df -h
295293

296294
# Check running processes
297-
lxc exec torrust-vm -- ps aux
295+
lxc exec torrust-tracker-vm -- ps aux
298296

299297
# Check cloud-init status
300-
lxc exec torrust-vm -- cloud-init status
298+
lxc exec torrust-tracker-vm -- cloud-init status
301299
```
302300

303301
For more LXD commands and troubleshooting, see the [LXD documentation](../../docs/tech-stack/lxd.md).

src/ansible/template/renderer/inventory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ mod tests {
224224

225225
let template_content = r#"all:
226226
hosts:
227-
torrust-vm:
227+
torrust-tracker-vm:
228228
ansible_host: {{ ansible_host }}
229229
ansible_user: torrust
230230
ansible_connection: ssh
@@ -314,7 +314,7 @@ mod tests {
314314
// Template requires {{ non_existent_field }} which won't be in context
315315
let template_content = r"all:
316316
hosts:
317-
torrust-vm:
317+
torrust-tracker-vm:
318318
ansible_host: {{ ansible_host }}
319319
ansible_user: torrust
320320
missing_field: {{ non_existent_field }}

0 commit comments

Comments
 (0)