--- - name: Deploy Docker Service Configurations hosts: rinoa vars: 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.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') | dirname }}" state: directory mode: '0755' loop: "{{ template_files.files }}" - name: Deploy rendered templates ansible.builtin.template: src: "{{ item.path }}" dest: "{{ appdata_base_path }}/{{ item.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') }}" mode: '0644' loop: "{{ template_files.files }}"