Repository navigation
Closed
Labels
Description
Overview
Add machine-readable JSON output format (--output-format json) to the provision command. This enables automation workflows to programmatically extract the provisioned instance IP address and connection details without regex parsing of console output.
Specification: docs/issues/352-add-json-output-to-provision-command.md
Parent Epic: #348 - Add JSON output format support
Related: #349 (completed reference implementation for create command)
Roadmap: Section 12.2
Goals
- Implement JSON output format for provision command
- Preserve existing human-readable output as default
- Enable automation to extract instance IP reliably
- Follow the architecture pattern established in Add JSON Output to create Command #349
Key Features
JSON Output
torrust-tracker-deployer provision my-env --output-format jsonReturns:
{
"environment_name": "my-env",
"instance_name": "torrust-tracker-vm-my-env",
"instance_ip": "10.140.190.39",
"ssh_username": "torrust",
"ssh_port": 22,
"ssh_private_key_path": "/path/to/key",
"provider": "lxd",
"provisioned_at": "2026-02-16T16:00:00Z",
"domains": ["tracker.example.com"]
}Critical Fields
- instance_ip: Most important for automation - enables automated workflows
- ssh_private_key_path: Enables automated SSH connections without manual key management
- domains: Enables automated DNS record updates for HTTPS deployments
Architecture
- Pattern: Strategy Pattern with TextView and JsonView (same as Add JSON Output to create Command #349)
- DDD Layer: Presentation (
src/presentation/views/commands/provision/) - Reference: Issue Add JSON Output to create Command #349 implementation serves as the pattern to follow
Implementation Phases
- Phase 0: Study create command reference implementation
- Phase 1: Create
ProvisionDetailsDataDTO - Phase 2: Implement TextView and JsonView
- Phase 3: Wire format switching in controller
- Phase 4: Update tests
- Phase 5: Testing and validation
- Phase 6: Documentation
Automation Use Cases
- SSH Connection Automation: Extract IP + credentials for automated SSH testing
- DNS Update Automation: Update DNS records immediately after provisioning
- Complete Deployment Pipeline: Provision → DNS → Wait for SSH → Configure → Release → Run
Acceptance Criteria
- ✅ JSON output with
--output-format jsonflag - ✅ Default text output unchanged
- ✅ All fields present and correct
- ✅ Works with both LXD and Hetzner providers
- ✅ Progress logs to stderr, JSON to stdout
- ✅ Pre-commit checks pass
- ✅ Documentation updated
Related Documentation
- Full specification: docs/issues/352-add-json-output-to-provision-command.md
- Reference implementation: Add JSON Output to create Command #349
- Output handling conventions: docs/contributing/output-handling.md
- DDD layer placement: docs/contributing/ddd-layer-placement.md
Activity
docs: add issue #352 specification for provision command JSON output
feat: [#352] add JSON output to provision command
docs: [#352] add JSON output documentation for provision command
docs: [#352] update roadmap and EPIC to reflect completion
Merge #354: refactor: separate view data from views in presentation l…
Merge #356: feat: [#355] add JSON output to show command
feat: [#357] add JSON output to run command
Merge #358: Add JSON Output to Run Command
Merge #360: Add JSON Output to List Command
chore: remove closed issue documentation files