Overview
Several Ansible playbook templates under templates/ansible/ hardcode the deployment directory as /opt/torrust instead of using the {{ deploy_dir }} variable sourced from variables.yml. This causes deployment failures when a user configures a custom deployment directory other than the default /opt/torrust.
The correct pattern — used by create-grafana-storage.yml, create-mysql-storage.yml, and deploy-grafana-provisioning.yml — is to load variables.yml via vars_files and reference {{ deploy_dir }} in all paths.
This bug was discovered while deploying the Torrust Tracker demo to the Hetzner provider (#405).
Specification
See detailed specification: docs/issues/409-fix-hardcoded-deploy-dir-in-ansible-templates.md
Implementation Plan
Phase 1: Fix fully hardcoded templates
Phase 2: Fix inline-variable templates
Phase 3: Update comments
Acceptance Criteria
Quality Checks:
Task-Specific Criteria:
Related
Overview
Several Ansible playbook templates under
templates/ansible/hardcode the deployment directory as/opt/torrustinstead of using the{{ deploy_dir }}variable sourced fromvariables.yml. This causes deployment failures when a user configures a custom deployment directory other than the default/opt/torrust.The correct pattern — used by
create-grafana-storage.yml,create-mysql-storage.yml, anddeploy-grafana-provisioning.yml— is to loadvariables.ymlviavars_filesand reference{{ deploy_dir }}in all paths.This bug was discovered while deploying the Torrust Tracker demo to the Hetzner provider (#405).
Specification
See detailed specification: docs/issues/409-fix-hardcoded-deploy-dir-in-ansible-templates.md
Implementation Plan
Phase 1: Fix fully hardcoded templates
create-tracker-storage.yml: Addvars_files: variables.ymland replace all 3 hardcoded loop items with{{ deploy_dir }}/storage/...create-prometheus-storage.yml: Addvars_files: variables.ymland replace the hardcoded loop itemcreate-backup-storage.yml: Addvars_files: variables.ymland replace 2 hardcodedpath:valuesdeploy-backup-config.yml: Addvars_files: variables.ymland replace all 4 hardcodeddest:/path:valuesdeploy-tracker-config.yml: Addvars_files: variables.ymland replace 2 hardcodeddest:/path:valuesdeploy-prometheus-config.yml: Addvars_files: variables.ymland replace 2 hardcodeddest:/path:valuesinit-tracker-database.yml: Addvars_files: variables.ymland replace 2 hardcodedpath:valuesdeploy-caddy-config.yml: Addvars_files: variables.ymland replace all 6 hardcoded occurrencesPhase 2: Fix inline-variable templates
run-compose-services.yml: Remove inlinedeploy_dir: /opt/torrustfromvarsand addvars_files: variables.ymlinsteaddeploy-compose-files.yml: Remove inlineremote_deploy_dir: /opt/torrustfromvars, addvars_files: variables.yml, and rename allremote_deploy_dirreferences todeploy_dirPhase 3: Update comments
{{ deploy_dir }}instead of/opt/torrustas the example path (where applicable)Acceptance Criteria
Quality Checks:
./scripts/pre-commit.shTask-Specific Criteria:
templates/ansible/uses a hardcoded/opt/torrustpath inpath:,dest:, or loop itemsvariables.ymlviavars_filesdeploy_diris used consistently (noremote_deploy_diror other aliases)vars:blocks for the deploy directory no longer define it inlinedeploy_dir: /opt/torrust) is unchangedRelated