Ansible pipeline.

This commit is contained in:
2025-06-12 06:33:31 -04:00
parent b769a6e449
commit a4ee173417
+22 -7
View File
@@ -1,27 +1,42 @@
---
- name: Deploy Docker Service Configurations - name: Deploy Docker Service Configurations
hosts: rinoa hosts: rinoa
vars: vars:
appdata_base_path: "~/.docker/config/appdata" appdata_base_path: "~/.docker/config/appdata"
template_base_path: "{{ playbook_dir }}/app-configs"
tasks: tasks:
- name: Recursively collect all Jinja2 templates (*.j2) - name: Recursively collect all Jinja2 templates (*.j2)
ansible.builtin.find: ansible.builtin.find:
paths: "app-configs" paths: "{{ template_base_path }}"
patterns: "*.j2" patterns: "*.j2"
recurse: true recurse: true
register: template_files register: template_files
- name: Set relative template path (without .j2) for each file
ansible.builtin.set_fact:
rel_template_path: >-
{{ item.path
| regex_replace('^' + (template_base_path | regex_escape) + '/', '')
| regex_replace('\\.j2$', '') }}
loop: "{{ template_files.files }}"
loop_control:
loop_var: item
register: rel_paths
- name: Ensure target directories exist - name: Ensure target directories exist
ansible.builtin.file: ansible.builtin.file:
path: "{{ appdata_base_path }}/{{ item.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') | dirname }}" path: "{{ appdata_base_path }}/{{ item.ansible_facts.rel_template_path | dirname }}"
state: directory state: directory
mode: '0755' mode: '0755'
loop: "{{ template_files.files }}" loop: "{{ rel_paths.results }}"
loop_control:
label: "{{ item.ansible_facts.rel_template_path }}"
- name: Deploy rendered templates - name: Deploy rendered templates
ansible.builtin.template: ansible.builtin.template:
src: "{{ item.path }}" src: "{{ item.item.path | regex_replace('^' + (playbook_dir | regex_escape) + '/', '') }}"
dest: "{{ appdata_base_path }}/{{ item.path | regex_replace('^app-configs/', '') | regex_replace('\\.j2$', '') }}" dest: "{{ appdata_base_path }}/{{ item.ansible_facts.rel_template_path }}"
mode: '0644' mode: '0644'
loop: "{{ template_files.files }}" loop: "{{ rel_paths.results }}"
loop_control:
label: "{{ item.ansible_facts.rel_template_path }}"