Skip to content

feat: [#180] implement configure CLI command - #182

Merged
josecelano merged 2 commits into
mainfrom
180-implement-configure-cli-command
Nov 18, 2025
Merged

josecelano merged 2 commits into
mainfrom
180-implement-configure-cli-command

Conversation

@josecelano

Copy link
Copy Markdown
Member

Overview

Implements the CLI presentation layer for the configure command, exposing the existing ConfigureCommandHandler application layer logic to end users. This enables users to transition deployment environments from "Provisioned" state to "Configured" state via the CLI interface.

Closes #180

Changes

Presentation Layer

  • ✅ Added Configure variant to Commands enum in src/presentation/input/cli/commands.rs
  • ✅ Created presentation controller in src/presentation/controllers/configure/:
    • mod.rs - Module documentation and exports
    • errors.rs - ConfigureSubcommandError with actionable .help() methods
    • handler.rs - Main controller with progress reporting
    • tests/mod.rs - Integration tests
  • ✅ Integrated configure command into router (src/presentation/dispatch/router.rs)
  • ✅ Added error handling in src/presentation/errors.rs

Application Layer Refactoring

  • ✅ Refactored ConfigureCommandHandler to match ProvisionCommandHandler pattern:
    • Removed ansible_client from constructor parameters
    • Added build_configuration_dependencies() method to create AnsibleClient internally
    • Updated all tests to use new constructor signature

Testing

  • ✅ All 291 unit tests pass
  • ✅ E2E tests pass (provision + destroy, configuration)
  • ✅ Manual E2E workflow verified:
    torrust-tracker-deployer create template test-config.json
    # Edit config
    torrust-tracker-deployer create environment -f test-config.json
    torrust-tracker-deployer provision test-env
    torrust-tracker-deployer configure test-env  # ← NEW COMMAND
    # Verified Docker & Docker Compose installed via SSH
    torrust-tracker-deployer destroy test-env

Manual Testing Results

✅ Full deployment workflow tested successfully:

  1. Generate template → Create environment → Provision infrastructure
  2. Configure environment (new command) - took 35.2s
  3. Verified via SSH:
    • Docker version 28.2.2 installed ✅
    • Docker Compose v2.29.2 installed ✅
  4. Cleanup successful

Known Issues

Issue #181: Hardcoded ansible_user in inventory template

  • Impact: Users must use username "torrust" (cannot use "ubuntu" or custom usernames)
  • Workaround: Use "username": "torrust" in configuration
  • Status: Documented in separate issue, will be fixed in future PR

Acceptance Criteria

All criteria from issue #180 met:

Functional Requirements:

  • ✅ torrust-tracker-deployer configure <name> command available
  • ✅ Validates environment is in "Provisioned" state
  • ✅ Configuration workflow executes (Docker, Docker Compose installation)
  • ✅ State transitions: Provisioned → Configuring → Configured
  • ✅ State persisted to repository

User Experience:

  • ✅ Progress reporting shows clear step-by-step feedback (9 steps)
  • ✅ Error messages include actionable help via .help() method
  • ✅ Command appears in main CLI --help output
  • ✅ Comprehensive documentation in --help configure

Code Quality:

  • ✅ Follows existing presentation layer patterns (matches provision controller)
  • ✅ Module organization matches provision command structure
  • ✅ No clippy warnings or rustfmt issues
  • ✅ Pre-commit checks pass

Testing:

  • ✅ Unit tests pass (291 passed)
  • ✅ Integration tests cover happy path and error cases
  • ✅ Manual E2E test confirms full deployment workflow

Related

- Add Configure variant to Commands enum
- Create presentation layer controller in src/presentation/controllers/configure/
- Implement ConfigureSubcommandError with actionable help messages
- Add router integration for configure command
- Refactor ConfigureCommandHandler to build AnsibleClient internally
- Update tests to match new dependency injection pattern
- Verify full deployment workflow: create → provision → configure → destroy
@josecelano josecelano self-assigned this Nov 18, 2025
@josecelano

Copy link
Copy Markdown
Member Author

ACK 1dbd0f6

@josecelano
josecelano merged commit c1265d1 into main Nov 18, 2025
@josecelano
josecelano deleted the 180-implement-configure-cli-command branch April 15, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Configure CLI Command

1 participant