You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Rationale**: Only 2 Ansible templates are dynamic (.tera): `inventory.yml.tera` and `variables.yml.tera`. All playbooks are static and load variables via `vars_files: [variables.yml]` directive. This follows the centralized variables pattern documented in `templates/ansible/README.md`.
61
+
62
+
2.**Step-Level Conditional Execution**:
63
+
64
+
-**Plan**: Add `grafana_enabled: bool` variable to `variables.yml.tera` for task-level conditionals
65
+
-**Actual**: No `grafana_enabled` variable; conditional execution happens at step level in handler
66
+
-**Rationale**: Grafana has a fixed port (3100), unlike tracker which has variable ports. Simpler to check `environment.context().user_inputs.grafana.is_some()` in the configure handler than pass boolean through templates. The playbook runs unconditionally when executed; the decision to execute happens in `ConfigureCommandHandler`.
67
+
68
+
3.**Module Locations**:
69
+
70
+
-**Plan**: Generic reference to `src/domain/environment/state.rs` for enum variant
71
+
-**Actual**: `src/domain/environment/state/configure_failed.rs` contains the `ConfigureStep::ConfigureGrafanaFirewall` variant
72
+
-**Note**: The state module is organized into separate files per state type (configure_failed.rs, release_failed.rs, etc.)
73
+
74
+
4.**Firewall Pattern**:
75
+
-**Prometheus**: Port 9090 is NOT exposed publicly through firewall (internal service only)
76
+
-**Grafana**: Port 3100 IS exposed publicly through UFW (user-facing UI)
77
+
-**Rationale**: Prometheus is an internal metrics collection service. Grafana is the user-facing visualization layer that accesses Prometheus internally.
31
78
32
79
## 🏗️ Architecture Requirements
33
80
@@ -37,8 +84,8 @@ _This section will be updated as implementation progresses._
37
84
-`src/infrastructure/templating/docker_compose/` - Docker Compose template rendering with Grafana service
**Ansible Playbook**: `templates/ansible/configure-grafana-firewall.yml` (NEW - static playbook, not .tera)
290
+
291
+
**Implementation Note**: Unlike the original plan which suggested a `.tera` dynamic template, the actual implementation uses a **static `.yml` playbook** that loads variables via `vars_files`. This follows the centralized variables pattern used by other Ansible playbooks in the project.
243
292
244
293
```yaml
245
294
---
246
295
# Configure Grafana-specific firewall rules
247
-
# Opens port 3100 for Grafana UI access (conditionally, only when Grafana is enabled)
- If Grafana is **enabled** in environment config → `ConfigureGrafanaFirewallStep` executes playbook → Port 3100 opened
338
+
- If Grafana is **disabled** (section absent) → Step skipped entirely (check: `environment.context().user_inputs.grafana.is_some()`)
339
+
- If `TORRUST_TD_SKIP_FIREWALL_IN_CONTAINER=true` → All firewall steps skipped (including Grafana)
340
+
341
+
- **Rationale for Step-Level Approach**:
342
+
- Grafana port is fixed (3100), unlike tracker's variable ports that need task-level conditionals
343
+
- Simpler to check Grafana presence at step level than pass boolean variable through templates
344
+
- Follows same pattern as Prometheus (which has no public firewall exposure at all)
345
+
- Playbook unconditionally opens port 3100 when executed - clean and predictable
286
346
287
347
**Security Note**: This public exposure is **temporary** until HTTPS support with reverse proxy is implemented (roadmap task 6). Once a reverse proxy (like nginx) is added with HTTPS, this public port exposure will be removed, and Grafana will only be accessible through the proxy.
2. Then, individual service ports are opened conditionally based on enabled services:
293
353
- SSH port (always, custom or default)
294
354
- Tracker ports (if tracker configured)
295
-
- Prometheus port (if Prometheus enabled)
296
-
- Grafana port (if Grafana enabled)
355
+
- **Prometheus port**: NOT exposed (internal service, no public firewall rule)
356
+
- Grafana port (if Grafana enabled) - port 3100 for UI access
297
357
- Future services...
298
358
359
+
**Note**: Prometheus (port 9090) is intentionally NOT exposed through the firewall as it's an internal service. Only Grafana (which provides the user-facing UI) has public firewall access.
0 commit comments