This document explains how the template system works in the Torrust Tracker Deploy tool.
The deployment tool uses templates to generate configuration files for infrastructure provisioning (OpenTofu) and software configuration (Ansible). Currently, templates are embedded in the binary for production use.
Templates are organized in the following structure:
templates/
├── ansible/ # Ansible playbooks and inventory templates
│ ├── inventory.yml.tera
│ ├── install-docker.yml
│ └── ...
└── tofu/ # OpenTofu infrastructure templates
└── lxd/ # LXD provider templates
├── main.tf
├── variables.tfvars.tera
└── cloud-init.yml.tera
- Templates are embedded in the binary during compilation
- No external files required for deployment
- Provides consistent, tested deployment configurations
- Templates are automatically extracted to build directory during deployment
- Files copied as-is to the build directory
- Examples:
main.tf,install-docker.yml - No variable substitution
- Use Tera templating engine for variable substitution
- Examples:
variables.tfvars.tera,inventory.yml.tera - Support runtime variables like
{{ instance_name }}
Common variables available in templates:
| Variable | Description | Example |
|---|---|---|
instance_name |
VM/container name | torrust-tracker-vm |
ansible_host |
Target server IP | 10.140.190.11 |
ssh_pub_key_content |
SSH public key | ssh-rsa AAAA... |
- Template Loading: Load embedded templates from binary
- Extraction: Copy templates to build directory
- Variable Resolution: Render
.teratemplates with runtime values - Deployment: Use generated files for infrastructure provisioning
- Templates are currently embedded and cannot be customized in production deployments
- All template modifications require recompilation of the binary
- Templates are tested as part of the CI/CD pipeline to ensure reliability
For development and testing purposes only, the system supports external template directories through the --templates-dir CLI argument. This is used internally for:
- E2E testing with fresh template states
- Development and debugging of template rendering
- Template validation during CI/CD
Note: This functionality is not available in production builds and is reserved for development and testing workflows.