Skip to content

Commit ec1d4cd

Browse files
committed
Merge #55: Document create environment command
7fe3690 docs: fix documentation link in create-environment.md (copilot-swe-agent[bot]) dbf216b docs: add comprehensive create environment command documentation (copilot-swe-agent[bot]) 9aa0675 Initial plan (copilot-swe-agent[bot]) Pull request description: Adds user-facing documentation for the `create environment` command, completing the final subissue of epic #34. ## Documentation Added - **Command reference** (`docs/user-guide/commands/create-environment.md`): - Syntax with all CLI flags and configuration format - JSON schema with field validation rules - 8 practical examples covering development, CI/CD, and production setups - Troubleshooting section for configuration validation, SSH keys, permissions, and parsing errors - Workflow integration with template generation and next steps - **Commands index updates** (`docs/user-guide/commands.md`): - Mark `create environment` and `create template` as ✅ Fully Implemented - Update workflow examples to include environment creation - Add `--working-dir` to common options ## Example Usage ```bash # Generate and edit configuration template torrust-tracker-deployer create template config.json nano config.json # Replace placeholders # Create environment torrust-tracker-deployer create environment --env-file config.json # With custom working directory torrust-tracker-deployer create environment \ --env-file config.json \ --working-dir /opt/deployments ``` Configuration format: ```json { "environment": { "name": "production" }, "ssh_credentials": { "private_key_path": "~/.ssh/id_rsa", "public_key_path": "~/.ssh/id_rsa.pub", "username": "torrust", "port": 22 } } ``` Closes #52 <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> ---- *This section details on the original issue you should resolve* <issue_title>[Subissue 10/10] Document Create Environment Command</issue_title> <issue_description># Document Create Environment Command **Epic Subissue**: 10 of 10 **Parent Epic**: [#34](#34) - Create Environment Command **Related**: [User Guide Commands](../user-guide/commands.md), [Create Environment Command Documentation](../user-guide/commands/create-environment.md) ## Overview Add comprehensive user-facing documentation for the `create environment` command to the user guide. This documentation will help users understand how to create new deployment environments from configuration files. The create environment command is now fully implemented (Subissues 1-7) and needs proper user-facing documentation in the `docs/user-guide/` directory. ## Goals - [ ] Create detailed command documentation at `docs/user-guide/commands/create-environment.md` - [ ] Update `docs/user-guide/commands.md` to mark create command as implemented - [ ] Include practical examples for common use cases - [ ] Document all command flags and configuration file formats - [ ] Provide troubleshooting guidance for common errors ## 🏗️ Architecture Requirements **Documentation Type**: User Guide **Module Path**: `docs/user-guide/commands/` **Pattern**: Command Reference Documentation ### Documentation Structure Requirements - [ ] Follow existing command documentation pattern (see [docs/user-guide/commands/destroy.md](../user-guide/commands/destroy.md)) - [ ] Include command synopsis, description, usage examples, and troubleshooting - [ ] Use clear, actionable language for user-facing documentation - [ ] Provide both JSON and TOML configuration examples ### Anti-Patterns to Avoid - ❌ Developer-focused implementation details in user guide - ❌ Missing practical examples - ❌ Unclear error troubleshooting guidance - ❌ Inconsistent formatting with other command docs ## Specifications ### Documentation Structure The command documentation should follow this structure: 1. **Command Overview** - Brief description of what the command does - When to use it - Implementation status badge 2. **Syntax** - Command signature with all flags - Required vs optional parameters 3. **Configuration File Format** - JSON format example - TOML format example - Field descriptions with validation rules 4. **Examples** - Basic usage (minimal configuration) - Advanced usage (custom working directory) - Template generation workflow 5. **Common Use Cases** - Development environment setup - Testing environment setup - Production environment setup 6. **Troubleshooting** - Configuration validation errors - File system permission issues - Invalid SSH key paths - Environment name conflicts 7. **Related Commands** - Link to provision command - Link to destroy command - Link to template generation ### Content to Include #### Command Overview Section ```markdown # Create Environment Command **Status**: ✅ Fully Implemented Create a new deployment environment from a configuration file. This command initializes the environment with validated configuration, SSH credentials, and prepares it for provisioning. **Use when**: - Setting up a new deployment environment - Initializing environment configuration from templates - Preparing environments for provisioning **Command**: `torrust-tracker-deployer create environment` ``` #### Syntax Section ````markdown ## Syntax ```bash torrust-tracker-deployer create environment --env-file <path> [options] ``` ```` ### Required Flags - `--env-file <path>` - Path to environment configuration file (JSON or TOML) ### Optional Flags - `--working-dir <path>` - Working directory for environment data (default: `.`) - `--log-output <mode>` - Logging output mode: `stderr`, `file`, `file-and-stderr` (default: `stderr`) ````<!-- markdownlint-disable-line MD040 --> #### Configuration Format Section ```markdown ## Configuration File Format ### JSON Format ```json { "environment": { "name": "my-environment" }, "ssh_credentials": { "private_key_path": "~/.ssh/id_rsa", "public_key_path": "~/.ssh/id_rsa.pub", "username": "deployer", "port": 22 } } ```` ### TOML Format ```toml [environment] name = "my-environment" [ssh_credentials] private_key_path = "~/.ssh/id_rsa" public_key_path = "~/.ssh/id_rsa.pub" username = "deployer" port = 22 ``` ### Field Descriptions - **environment.name** (required): Unique environment identifier - Must be lowercase alphanumeric with hyphens - Used for directory names and resource identification - **ssh_credentials.private_key_path** (required): Path to SSH private key - Supports `~` for home directory expansion - File must exist and be readable - **ssh_credentials.public_key_path** (required): Path to SSH public key - Supports `~` for home directory expansion... </details> - Fixes #52 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/torrust/torrust-tracker-deployer/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. ACKs for top commit: josecelano: ACK 7fe3690 Tree-SHA512: 070ffcc553d9c68bd8b7f0679918c19c009b9e8fa532949f84b8d4f3daf6a5d3b1c4144f41b5971f4017a07b60039e221b1332f18226115eff7c917345d690b6
2 parents 3f24109 + 7fe3690 commit ec1d4cd

2 files changed

Lines changed: 657 additions & 31 deletions

File tree

docs/user-guide/commands.md

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ This guide provides an overview of the available commands for the Torrust Tracke
44

55
## ⚠️ Implementation Status
66

7-
**Current State**: The `destroy` command is fully implemented with CLI interface.
7+
**Current State**: The `create` and `destroy` commands are fully implemented with CLI interface.
88

9-
-**Implemented**: `destroy` command
9+
-**Implemented**: `create environment`, `create template`, `destroy` commands
1010
-**CLI Interface**: Other commands not yet implemented
1111

1212
The CLI commands documented here represent the planned MVP implementation.
1313

1414
## Planned Commands (MVP)
1515

1616
```bash
17-
# Available command
18-
torrust-tracker-deployer destroy <env> # Destroy infrastructure and clean up resources
17+
# Available commands
18+
torrust-tracker-deployer create environment --env-file <file> # Create new deployment environment
19+
torrust-tracker-deployer create template [path] # Generate configuration template
20+
torrust-tracker-deployer destroy <env> # Destroy infrastructure and clean up resources
1921

2022
# Future commands
21-
torrust-tracker-deployer create <env> # Future - Create environment configuration
2223
torrust-tracker-deployer deploy <env> # Future - Full deployment (provision → configure → release)
2324
torrust-tracker-deployer run <env> # Future - Start application services
2425
torrust-tracker-deployer status <env> # Future - Check environment status
@@ -31,6 +32,46 @@ torrust-tracker-deployer test <env> # Future - Run validation tests
3132

3233
### Environment Management
3334

35+
#### [`create environment`](commands/create-environment.md)
36+
37+
Create a new deployment environment from a configuration file.
38+
39+
**Status**: ✅ Fully Implemented
40+
41+
**Use when**: Initializing new environments for development, testing, or production
42+
43+
```bash
44+
torrust-tracker-deployer create environment --env-file ./config/environment.json
45+
```
46+
47+
Creates:
48+
49+
- Environment data directory
50+
- Initial environment state (Created)
51+
- Persistent configuration
52+
53+
---
54+
55+
#### `create template`
56+
57+
Generate a configuration template file for environment creation.
58+
59+
**Status**: ✅ Fully Implemented
60+
61+
**Use when**: Starting a new environment configuration from scratch
62+
63+
```bash
64+
# Generate template with default name
65+
torrust-tracker-deployer create template
66+
67+
# Generate template with custom name
68+
torrust-tracker-deployer create template my-config.json
69+
```
70+
71+
Creates: JSON configuration template with placeholder values
72+
73+
---
74+
3475
#### [`destroy`](commands/destroy.md)
3576

3677
Remove environment and clean up all resources.
@@ -55,21 +96,6 @@ Removes:
5596

5697
### Future Commands
5798

58-
#### `create` (Planned)
59-
60-
Create a new environment configuration.
61-
62-
**Status**: ❌ Not Yet Implemented
63-
64-
**Use when**: Initializing a new deployment environment
65-
66-
```bash
67-
# Planned CLI usage
68-
torrust-tracker-deployer create my-environment
69-
```
70-
71-
---
72-
7399
#### `deploy` (Planned)
74100

75101
Complete deployment workflow that orchestrates provision → configure → release.
@@ -143,25 +169,36 @@ torrust-tracker-deployer test my-environment
143169
The recommended workflow once all commands are implemented:
144170

145171
```bash
146-
# 1. Create environment configuration
147-
torrust-tracker-deployer create production
172+
# 1. Generate configuration template
173+
torrust-tracker-deployer create template production-config.json
148174

149-
# 2. Deploy complete stack (provision → configure → release)
175+
# 2. Edit the configuration file
176+
nano production-config.json
177+
178+
# 3. Create environment configuration
179+
torrust-tracker-deployer create environment --env-file production-config.json
180+
181+
# 4. Deploy complete stack (provision → configure → release)
150182
torrust-tracker-deployer deploy production
151183

152-
# 3. Start services
184+
# 5. Start services
153185
torrust-tracker-deployer run production
154186

155-
# 4. Verify deployment
187+
# 6. Verify deployment
156188
torrust-tracker-deployer status production
157189
torrust-tracker-deployer test production
158190
```
159191

160192
### Development/Testing Workflow
161193

194+
Current available commands for development and testing:
195+
162196
```bash
163-
# Note: Only destroy command is currently implemented
164-
torrust-tracker-deployer destroy test-env
197+
# 1. Create environment from configuration
198+
torrust-tracker-deployer create environment --env-file dev-config.json
199+
200+
# 2. When done, clean up
201+
torrust-tracker-deployer destroy dev-env
165202
```
166203

167204
## Environment States
@@ -181,13 +218,14 @@ Created → Provisioned → Configured → Released → Running → Destroyed
181218

182219
## Common Options
183220

184-
The destroy command supports these options:
221+
The create and destroy commands support these common options:
185222

186223
- `--help` - Display command help
187224
- `--log-output <OUTPUT>` - Logging destination (`file-only` or `file-and-stderr`)
188225
- `--log-file-format <FORMAT>` - File log format (`pretty`, `json`, or `compact`)
189226
- `--log-stderr-format <FORMAT>` - Stderr log format (`pretty`, `json`, or `compact`)
190227
- `--log-dir <DIR>` - Log directory (default: `./data/logs`)
228+
- `--working-dir <DIR>` - Working directory for environment data (default: `.`)
191229

192230
### Environment Variables
193231

@@ -197,12 +235,14 @@ The destroy command supports these options:
197235

198236
New users should:
199237

200-
1. Start with the [`destroy` command documentation](commands/destroy.md) to understand the workflow
201-
2. Review the deployment states and standard workflow
202-
3. Consult individual command documentation as more commands become available
238+
1. Start with the [`create environment` command documentation](commands/create-environment.md) to set up your first environment
239+
2. Use the [`create template` command](#create-template) to generate a configuration file
240+
3. Review the [`destroy` command documentation](commands/destroy.md) to understand cleanup workflow
241+
4. Consult individual command documentation as more commands become available
203242

204243
## Related Documentation
205244

245+
- [Create Environment Command](commands/create-environment.md) - Detailed create environment command documentation
206246
- [Destroy Command](commands/destroy.md) - Detailed destroy command documentation
207247
- [Logging Guide](../logging.md) - Configure logging output
208248
- [E2E Testing](../../e2e-testing.md) - Testing infrastructure and commands

0 commit comments

Comments
 (0)