From 6fc0cbbf3e2d4df738da3d1a591f922fa0378aec Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sun, 31 Aug 2025 18:58:42 -0400 Subject: [PATCH 1/4] Tweaking Ansible playbook. --- tar-valon_config_deploy.yml | 41 ++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/tar-valon_config_deploy.yml b/tar-valon_config_deploy.yml index f8334be..c799830 100644 --- a/tar-valon_config_deploy.yml +++ b/tar-valon_config_deploy.yml @@ -10,21 +10,47 @@ # template_base_path and vault_addr from group_vars/all.yml # appdata_base_path, secrets_path, vault_token_cleaned from host_vars/.yml - tasks: + pre_tasks: - name: Find all files for this host ansible.builtin.find: paths: "{{ template_base_path }}/{{ inventory_hostname }}" - recurse: yes + recurse: true register: host_files delegate_to: localhost run_once: true + run_on_delegate: true + + - name: Build list of unique destination directories + ansible.builtin.set_fact: + dest_dirs: >- + {{ + host_files.files + | map(attribute='path') + | map('relpath', template_base_path ~ '/' ~ inventory_hostname) + | map('dirname') + | map('path_join', appdata_base_path) + | unique + | list + }} + + tasks: + - name: Ensure destination directories exist (unique set) + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: "{{ dest_dirs }}" + loop_control: + label: "{{ item }}" - name: Deploy Jinja2 templates (skip unchanged) ansible.builtin.template: src: "{{ item.path }}" - dest: "{{ appdata_base_path }}/{{ item.path | relpath(template_base_path + '/' + inventory_hostname) | regex_replace('\\.j2$', '') }}" + dest: >- + {{ appdata_base_path }}/{{ item.path + | relpath(template_base_path + '/' + inventory_hostname) + | regex_replace('\.j2$', '') }} mode: '0644' - create_dirs: yes loop: "{{ host_files.files }}" loop_control: label: "{{ item.path }}" @@ -33,10 +59,11 @@ - name: Deploy static files (skip unchanged) ansible.builtin.copy: src: "{{ item.path }}" - dest: "{{ appdata_base_path }}/{{ item.path | relpath(template_base_path + '/' + inventory_hostname) }}" + dest: >- + {{ appdata_base_path }}/{{ item.path + | relpath(template_base_path + '/' + inventory_hostname) }} mode: '0644' - remote_src: no - create_dirs: yes + remote_src: false loop: "{{ host_files.files }}" loop_control: label: "{{ item.path }}" -- 2.52.0 From 71c97de6fff9176fe5a85e2f839e118f2020a1f3 Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sun, 31 Aug 2025 19:02:28 -0400 Subject: [PATCH 2/4] Tweaking Ansible playbook and Gitea workflow. --- .gitea/workflows/gitea_tar-valon_ansible_deploy.yml | 1 + tar-valon_config_deploy.yml | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/gitea_tar-valon_ansible_deploy.yml b/.gitea/workflows/gitea_tar-valon_ansible_deploy.yml index d741084..52c8f3b 100644 --- a/.gitea/workflows/gitea_tar-valon_ansible_deploy.yml +++ b/.gitea/workflows/gitea_tar-valon_ansible_deploy.yml @@ -10,6 +10,7 @@ on: - 'inventory/hosts.yml' - 'host_vars/**' - 'group_vars/**' + - '**/tar-valon_config_deploy.yml' - '**/gitea_tar-valon_ansible_deploy.yml' env: diff --git a/tar-valon_config_deploy.yml b/tar-valon_config_deploy.yml index c799830..873d912 100644 --- a/tar-valon_config_deploy.yml +++ b/tar-valon_config_deploy.yml @@ -18,7 +18,7 @@ register: host_files delegate_to: localhost run_once: true - run_on_delegate: true + changed_when: false # ensures this task never shows as "changed" - name: Build list of unique destination directories ansible.builtin.set_fact: @@ -32,6 +32,7 @@ | unique | list }} + changed_when: false # computing vars does not constitute a change tasks: - name: Ensure destination directories exist (unique set) @@ -48,7 +49,7 @@ src: "{{ item.path }}" dest: >- {{ appdata_base_path }}/{{ item.path - | relpath(template_base_path + '/' + inventory_hostname) + | relpath(template_base_path ~ '/' ~ inventory_hostname) | regex_replace('\.j2$', '') }} mode: '0644' loop: "{{ host_files.files }}" @@ -61,7 +62,7 @@ src: "{{ item.path }}" dest: >- {{ appdata_base_path }}/{{ item.path - | relpath(template_base_path + '/' + inventory_hostname) }} + | relpath(template_base_path ~ '/' ~ inventory_hostname) }} mode: '0644' remote_src: false loop: "{{ host_files.files }}" -- 2.52.0 From bc5e3f673a8c44ecf851f45e34fc184e0a50f8f6 Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sun, 31 Aug 2025 19:05:32 -0400 Subject: [PATCH 3/4] .... --- tar-valon_config_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tar-valon_config_deploy.yml b/tar-valon_config_deploy.yml index 873d912..4590804 100644 --- a/tar-valon_config_deploy.yml +++ b/tar-valon_config_deploy.yml @@ -28,7 +28,7 @@ | map(attribute='path') | map('relpath', template_base_path ~ '/' ~ inventory_hostname) | map('dirname') - | map('path_join', appdata_base_path) + | map('community.general.path_join', appdata_base_path) | unique | list }} -- 2.52.0 From abe78c986a02d75f0fa291f4a9a26faff42ebfdb Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sun, 31 Aug 2025 19:08:47 -0400 Subject: [PATCH 4/4] .... --- tar-valon_config_deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tar-valon_config_deploy.yml b/tar-valon_config_deploy.yml index 4590804..986e9ef 100644 --- a/tar-valon_config_deploy.yml +++ b/tar-valon_config_deploy.yml @@ -18,7 +18,7 @@ register: host_files delegate_to: localhost run_once: true - changed_when: false # ensures this task never shows as "changed" + changed_when: false - name: Build list of unique destination directories ansible.builtin.set_fact: @@ -28,11 +28,11 @@ | map(attribute='path') | map('relpath', template_base_path ~ '/' ~ inventory_hostname) | map('dirname') - | map('community.general.path_join', appdata_base_path) + | map('regex_replace', '^(.*)$', appdata_base_path ~ '/\1') | unique | list }} - changed_when: false # computing vars does not constitute a change + changed_when: false tasks: - name: Ensure destination directories exist (unique set) -- 2.52.0