Commit d059cc9
committed
Merge #110: Convert firewall template to centralized variables pattern
73845dc fix: [#106] mark doctest as no_run to prevent ansible-playbook dependency (copilot-swe-agent[bot])
9a7d40e style: [#106] apply cargo fmt formatting (copilot-swe-agent[bot])
e71f865 docs: [#106] update documentation for centralized variables pattern (copilot-swe-agent[bot])
18a0514 feat: [#106] delete firewall renderer and wrapper modules (~675 lines) (copilot-swe-agent[bot])
e5bfba3 feat: [#106] remove firewall template rendering and delete old .tera file (copilot-swe-agent[bot])
ed71281 feat: [#106] convert firewall template to static with vars_files and update API (copilot-swe-agent[bot])
153011e Initial plan (copilot-swe-agent[bot])
Pull request description:
## ✅ Complete Vertical Slice: Convert Firewall Template to Variables Pattern
This PR successfully implements a complete vertical slice to convert the `configure-firewall.yml.tera` template to use the centralized variables pattern, following issue #106 specification.
### 🎯 All Phases Complete
- [x] Phase 1: Convert template file to static with vars_files
- [x] Phase 2: Register static template in copy_static_templates()
- [x] Phase 3: Update AnsibleClient signature to accept extra_args
- [x] Phase 4: Update all AnsibleClient call sites
- [x] Phase 5: Update ConfigureFirewallStep to use variables file
- [x] Phase 6: Remove old firewall template rendering
- [x] Phase 7: Delete old .tera template file
- [x] Phase 8: Clean up firewall renderer/wrapper code (~675 lines removed)
- [x] Phase 9: Update documentation
- [x] Phase 10: Final validation (tests, linters, build verification)
- [x] Fix doctest failure
### 📋 Changes Summary
#### Template Conversion
- ✅ Created static `configure-firewall.yml` (no `.tera` extension)
- ✅ Added `vars_files: [variables.yml]` directive to playbook
- ✅ Fixed variable syntax: `{{ssh_port}}` → `{{ ssh_port }}` (proper spacing)
- ✅ Deleted old `configure-firewall.yml.tera`
#### API Updates
- ✅ Updated `AnsibleClient::run_playbook()` signature to accept `extra_args: &[&str]`
- ✅ Updated all 5 call sites for backward compatibility
- ✅ Added comprehensive rustdoc with examples
- ✅ Fixed doctest to use `no_run` attribute (prevents ansible-playbook requirement in CI)
#### Static Registration
- ✅ Added `configure-firewall.yml` to static playbooks list in `copy_static_templates()`
- ✅ Updated file count in debug log: 6 → 7
#### Rendering Cleanup
- ✅ Removed `firewall_playbook_renderer` field from `AnsibleTemplateRenderer`
- ✅ Removed renderer initialization in constructor
- ✅ Removed firewall rendering call from `render()` method
- ✅ Removed `create_firewall_context()` helper method
- ✅ Removed `FirewallPlaybookRenderingFailed` error variant
- ✅ Removed `FirewallPlaybookTemplateRenderer` from public exports
#### Code Cleanup (~675 lines removed)
- ✅ Deleted `src/infrastructure/external_tools/ansible/template/renderer/firewall_playbook.rs` (347 lines)
- ✅ Deleted `src/infrastructure/external_tools/ansible/template/wrappers/firewall_playbook/` directory (328 lines)
- ✅ Removed module exports from `wrappers/mod.rs`
- ✅ Removed module exports from `renderer/mod.rs`
- ✅ Verified zero remaining references in codebase
#### Documentation Updates
- ✅ Updated `docs/technical/template-system-architecture.md`
- ✅ Updated `docs/contributing/templates.md`
- ✅ Updated `templates/ansible/README.md`
### ✅ Validation Complete
**Tests**:
- ✅ All unit tests pass: `cargo test` (1065 tests, 0 failures)
- ✅ All doc tests pass: `cargo test --doc` (233 tests, 0 failures)
- ✅ Build succeeds: `cargo build --release`
**Linters**:
- ✅ All linters pass: `cargo run --bin linter all`
- ✅ No unused dependencies: `cargo machete`
**Template Verification**:
- ✅ Static `configure-firewall.yml` copied to build directory
- ✅ Playbook contains `vars_files: [variables.yml]`
- ✅ `variables.yml` generated with correct SSH port
### 📊 Impact
- **Net change**: +184 insertions, -765 deletions
- **Complexity reduced**: No per-playbook renderer/wrapper/context needed
- **Pattern established**: Future playbooks can follow this simpler approach
- **Maintainability improved**: Centralized variable management
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Convert Firewall Template to Variables Pattern (Complete Vertical Slice)</issue_title>
> <issue_description>**Parent Epic**: #19 - Refactor Ansible Templates to Variables Pattern
> **Depends On**: #105 - Create Variables Template Infrastructure
>
> ## Overview
>
> Convert the `configure-firewall.yml.tera` template to a static `configure-firewall.yml` playbook that loads variables from the centralized `variables.yml` file. This is a **complete vertical slice** that includes implementation, cleanup of old code, documentation updates, and full validation.
>
> ## Goals
>
> - [ ] **Template Conversion**: Convert `.tera` template to static `.yml` playbook
> - [ ] **Variables Integration**: Add `vars_files: [variables.yml]` to load centralized variables
> - [ ] **Static Registration**: Register playbook in `copy_static_templates()` method
> - [ ] **AnsibleClient Enhancement**: Make generic to accept optional extra arguments
> - [ ] **Call Site Updates**: Update all AnsibleClient call sites for new signature
> - [ ] **Cleanup**: Remove old firewall renderer/wrapper code (~500 lines)
> - [ ] **Documentation**: Update architecture docs, contributing guide, templates README
> - [ ] **Validation**: Full test suite, build verification, E2E preparation
>
> ## 🏗️ Architecture Requirements
>
> **DDD Layer**: Infrastructure (template system) + Adapters (AnsibleClient)
>
> **Pattern**: Static template copying + Ansible vars_files
>
> ## Time Estimate
>
> **4.5 days** - Complete vertical slice (11 phases):
> - Phases 1-8: Template conversion and API updates (2.75 days)
> - Phase 9: Clean up old architecture (2-3 hours)
> - Phase 10: Update documentation (1-2 hours)
> - Phase 11: Final integration validation (0.5-1 hour)
>
> ## Documentation
>
> Full implementation details: [`docs/issues/19.2-convert-firewall-template-to-static.md`](https://github.com/torrust/torrust-tracker-deployer/blob/copilot/configure-ufw-firewall/docs/issues/19.2-convert-firewall-template-to-static.md)
>
> ## Acceptance Criteria
>
> ### Template Conversion
> - [ ] `configure-firewall.yml` is static (no `.tera` extension)
> - [ ] Playbook contains `vars_files: [variables.yml]`
> - [ ] Old `.tera` template deleted
>
> ### API Updates
> - [ ] `AnsibleClient::run_playbook()` accepts `extra_args` parameter
> - [ ] All call sites updated to new signature
> - [ ] Firewall step passes `&["-e", "@variables.yml"]`
>
> ### Cleanup (~500 lines removed)
> - [ ] `firewall_playbook.rs` renderer deleted (~350 lines)
> - [ ] `wrappers/firewall_playbook/` directory deleted (~150 lines)
> - [ ] Module exports removed
> - [ ] No remaining references in codebase
>
> ### Documentation
> - [ ] Template system architecture updated
> - [ ] Contributing templates guide updated
> - [ ] Templates README updated
> - [ ] Examples for future developers
>
> ### Testing & Validation
> - [ ] Unit tests pass: `cargo test`
> - [ ] Config tests pass: `cargo run --bin e2e-config-tests`
> - [ ] Linters pass: `cargo run --bin linter all`
> - [ ] Build directory structure verified
> - [ ] Template contents verified
>
> ## Related
>
> - Parent Epic: #19
> - Previous Task: #105 (must complete first)
> - [Ansible vars_files Documentation](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#defining-variables-in-files)</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixes #106
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
ACKs for top commit:
josecelano:
ACK 73845dc
Tree-SHA512: e222988a51dee9c465c83276faeeee611febf8e61649e7b390cf1cf60957b7fcb00348446cfd18a74e0562ff5f14d9684727b9bd22e0c8eb35bb8819f91a97ca15 files changed
Lines changed: 184 additions & 765 deletions
File tree
- docs
- contributing
- technical
- src
- adapters/ansible
- application/steps
- software
- system
- infrastructure/external_tools/ansible/template
- renderer
- wrappers
- firewall_playbook
- templates/ansible
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
277 | 343 | | |
278 | 344 | | |
279 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
55 | 99 | | |
56 | 100 | | |
57 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
| |||
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
74 | 95 | | |
75 | 96 | | |
76 | 97 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 98 | + | |
82 | 99 | | |
83 | 100 | | |
84 | 101 | | |
| |||
140 | 157 | | |
141 | 158 | | |
142 | 159 | | |
143 | | - | |
| 160 | + | |
144 | 161 | | |
145 | 162 | | |
146 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
0 commit comments