From 385b4a68023017950c51a90f5200b6866c8c14b3 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 28 Jul 2026 00:46:19 +0200 Subject: [PATCH] refactor(copy_files.yml): simplify template file handling by removing redundant tasks --- roles/common/tasks/copy_files.yml | 42 +------------------------------ 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/roles/common/tasks/copy_files.yml b/roles/common/tasks/copy_files.yml index c850ec6..1a124c5 100644 --- a/roles/common/tasks/copy_files.yml +++ b/roles/common/tasks/copy_files.yml @@ -161,43 +161,8 @@ - copy-plain-files notify: "Reload postfwd" -- name: (copy_files.yml) HOST-TREE collect host specific template files by directory structure - ansible.builtin.find: - paths: "{{ role_path }}/templates/{{ inventory_hostname }}" - recurse: true - file_type: file - patterns: "*.j2" - delegate_to: localhost - become: false - register: common_host_template_files - when: - - inventory_hostname in groups['mail_server'] - - common_host_template_dir.stat.exists - - common_host_template_dir.stat.isdir - tags: - - copy-files - - copy-template-files -- name: (copy_files.yml) HOST-TREE render host specific template files by directory structure - ansible.builtin.template: - src: "{{ item.path }}" - dest: "/{{ item.path | regex_replace('^' ~ (role_path ~ '/templates/' ~ inventory_hostname ~ '/'), '') | regex_replace('\\.j2$', '') }}" - owner: root - group: root - mode: "0644" - loop: "{{ common_host_template_files.files }}" - loop_control: - label: "dest: /{{ item.path | regex_replace('^' ~ (role_path ~ '/templates/' ~ inventory_hostname ~ '/'), '') | regex_replace('\\.j2$', '') }}" - when: - - inventory_hostname in groups['mail_server'] - - common_host_template_dir.stat.exists - - common_host_template_dir.stat.isdir - - common_host_template_files.files | length > 0 - tags: - - copy-files - - copy-template-files - -- name: (copy_files.yml) GLOBAL copy template files (variable list) +- name: (copy_files.yml) copy template files ansible.builtin.template: src: "{{ item.src_path }}" dest: "{{ item.dest_path }}" @@ -210,11 +175,6 @@ when: - copy_template_files is defined - copy_template_files|length > 0 - - not ( - inventory_hostname in groups['mail_server'] and - common_host_template_dir.stat.exists and - (lookup('ansible.builtin.fileglob', role_path ~ '/templates/' ~ inventory_hostname ~ item.dest_path ~ '.j2', wantlist=True) | length > 0) - ) tags: - copy-files - copy-template-files