resolve compose template via ansible search path instead of absolute app_templates_path
This commit is contained in:
+1
-1
@@ -315,7 +315,7 @@ The `templates/` directory of the calling shim role is discovered automatically
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `app_compose_template` | `{{ app_templates_path }}/compose.yml.j2` | Template file path |
|
||||
| `app_compose_template` | `compose.yml.j2` | Template file path — relative names resolve via Ansible's role templates search path (finds the calling shim role's `templates/`); absolute paths also accepted |
|
||||
| `app_compose_file` | - | Static compose file path |
|
||||
| `app_compose_content` | - | Inline compose content |
|
||||
| `app_compose_validate` | `true` | Validate compose syntax |
|
||||
|
||||
@@ -30,11 +30,10 @@ app_health_check_retries: 30
|
||||
app_health_check_delay: 10
|
||||
app_health_check_status_codes: [200, 201, 202]
|
||||
|
||||
# Templates path derives from the caller (shim) role's directory, so shim
|
||||
# roles in any collection layout Just Work. ansible_parent_role_paths[0] is
|
||||
# the absolute path of the role that pulled this one in as a dep.
|
||||
app_templates_path: "{{ ansible_parent_role_paths[0] }}/templates"
|
||||
app_compose_template: "{{ app_templates_path }}/compose.yml.j2"
|
||||
# Relative src — Ansible's template resolver searches loaded roles' templates/
|
||||
# directories, so this finds the calling (shim) role's compose.yml.j2 without
|
||||
# any absolute-path plumbing.
|
||||
app_compose_template: compose.yml.j2
|
||||
|
||||
app_subdirectories: []
|
||||
# - config
|
||||
|
||||
@@ -48,21 +48,6 @@
|
||||
- not (app_dir is match('.*\.\..*'))
|
||||
fail_msg: "Security validation failed for {{ app_name }}: app_dir '{{ app_dir }}' contains invalid characters or path traversal sequences"
|
||||
|
||||
- name: Check if compose template exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ app_compose_template }}"
|
||||
register: _compose_template_stat
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
when: app_compose_template is defined and app_compose_template | length > 0
|
||||
|
||||
- name: Assert compose template exists
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _compose_template_stat.stat.exists
|
||||
fail_msg: "Template file not found for {{ app_name }}: '{{ app_compose_template }}' does not exist"
|
||||
when: app_compose_template is defined and app_compose_template | length > 0
|
||||
|
||||
- name: Check if compose file exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ app_compose_file }}"
|
||||
|
||||
Reference in New Issue
Block a user