Expand description
Template Rendering Services
This module contains application-layer services for rendering infrastructure
templates. Each service encapsulates the logic for rendering a specific type
of template (Ansible, OpenTofu, Docker Compose, etc.) and is designed to be
shared across multiple command handlers and steps.
§Architecture
Rendering services follow the DDD application layer pattern:
- Orchestrate: Bridge multiple domain types into infrastructure generator calls
- Transform: Map domain types to template-specific context types
- Decide: Apply conditional logic (e.g., “if Prometheus is configured, include it”)
§Services
AnsibleTemplateRenderingService- Renders Ansible inventory and playbook templatesOpenTofuTemplateRenderingService- RendersOpenTofuinfrastructure templatesTrackerTemplateRenderingService- Renders Tracker configuration templatesPrometheusTemplateRenderingService- Renders Prometheus configuration templatesGrafanaTemplateRenderingService- Renders Grafana provisioning templatesDockerComposeTemplateRenderingService- Renders Docker Compose configuration templatesCaddyTemplateRenderingService- Renders Caddy TLS proxy configuration templatesBackupTemplateRenderingService- Renders backup configuration templates
§Design Principles
All rendering services follow these principles:
-
Explicit Inputs: Services take explicit domain config types (e.g.,
&TrackerConfig) rather thanEnvironment<S>. This makes dependencies clear and allows both the render command handler and the release steps to call them. -
Factory Pattern: Services use
from_paths()orfrom_params()factory methods that accepttemplates_dir,build_dir, andclockas construction parameters. -
Single Responsibility: Each service handles exactly one template type and its associated context building logic.
-
Error Wrapping: Services define thin error types that wrap infrastructure generator errors while preserving context.
§Usage Example
use std::sync::Arc;
use torrust_tracker_deployer_lib::application::services::rendering::AnsibleTemplateRenderingService;
use torrust_tracker_deployer_lib::shared::clock::SystemClock;
let service = AnsibleTemplateRenderingService::from_paths(
templates_dir,
build_dir,
Arc::new(SystemClock),
);
service.render_templates(&user_inputs, instance_ip, None).await?;Structs§
- Ansible
Template Rendering Service - Service for rendering Ansible templates with runtime configuration
- Backup
Template Rendering Service - Service for rendering backup configuration templates
- Caddy
Template Rendering Service - Service for rendering Caddy TLS proxy templates
- Docker
Compose Template Rendering Service - Service for rendering Docker Compose templates
- Grafana
Template Rendering Service - Service for rendering Grafana provisioning templates
- Open
Tofu Template Rendering Service - Service for rendering
OpenTofuinfrastructure templates - Prometheus
Template Rendering Service - Service for rendering Prometheus configuration templates
- Tracker
Template Rendering Service - Service for rendering Tracker configuration templates
Enums§
- Ansible
Template Rendering Service Error - Errors that can occur during Ansible template rendering
- Backup
Template Rendering Service Error - Errors that can occur during backup template rendering
- Caddy
Template Rendering Service Error - Errors that can occur during Caddy template rendering
- Docker
Compose Template Rendering Service Error - Errors that can occur during Docker Compose template rendering
- Grafana
Template Rendering Service Error - Errors that can occur during Grafana template rendering
- Open
Tofu Template Rendering Service Error - Errors that can occur during
OpenTofutemplate rendering - Prometheus
Template Rendering Service Error - Errors that can occur during Prometheus template rendering
- Tracker
Template Rendering Service Error - Errors that can occur during Tracker template rendering