From 61718cbc59997e9844bf174291dc34e8bff101f1 Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Wed, 11 Jun 2025 20:17:16 -0400 Subject: [PATCH] Modifying Playbook to adhere to dir structure. --- ansible/docker_config_deploy.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ansible/docker_config_deploy.yml b/ansible/docker_config_deploy.yml index 798016c4..16c1fd31 100644 --- a/ansible/docker_config_deploy.yml +++ b/ansible/docker_config_deploy.yml @@ -5,16 +5,23 @@ appdata_base_path: "~/.docker/config/appdata" tasks: + - name: Recursively collect all Jinja2 templates (*.j2) + ansible.builtin.find: + paths: "app-configs" + patterns: "*.j2" + recurse: true + register: template_files + - name: Ensure target directories exist ansible.builtin.file: - path: "{{ appdata_base_path }}/{{ (item | basename | regex_replace('\\.j2$', '') | regex_replace('_', '/') | regex_replace('/[^/]+$', '')) }}" + path: "{{ appdata_base_path }}/{{ item.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') | dirname }}" state: directory mode: '0755' - loop: "{{ query('fileglob', 'app-configs/*.j2') }}" + loop: "{{ template_files.files }}" - - name: Deploy configuration templates + - name: Deploy rendered templates ansible.builtin.template: - src: "{{ item }}" - dest: "{{ appdata_base_path }}/{{ item | basename | regex_replace('\\.j2$', '') | regex_replace('_', '/') }}" + src: "{{ item.path }}" + dest: "{{ appdata_base_path }}/{{ item.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') }}" mode: '0644' - loop: "{{ query('fileglob', 'app-configs/*.j2') }}" + loop: "{{ template_files.files }}"