From a0e3f16c72eaeb5d7d1809484e761bab1ddfb7c7 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sat, 23 Aug 2025 19:37:04 +0200 Subject: [PATCH] sys_fetch.yaml --- playbooks.templates/sys_fetch.yaml | 3 ++- tasks.templates/t_sys_fetch_directory.yaml | 8 +++++--- tasks.templates/t_sys_fetch_file.yaml | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/playbooks.templates/sys_fetch.yaml b/playbooks.templates/sys_fetch.yaml index b3ea245..f4dec24 100644 --- a/playbooks.templates/sys_fetch.yaml +++ b/playbooks.templates/sys_fetch.yaml @@ -11,11 +11,12 @@ sourceFile: "{{ item.source }}" targetFile: "{{ item.target }}" with_items: "{{ sys_fetch_files }}" + when: false - name: Fetch the directories ansible.builtin.include_tasks: ../tasks/t_sys_fetch_directory.yaml vars: sourceDir: "{{ item.source }}" targetDir: "{{ item.target }}" with_items: "{{ sys_fetch_directories }}" - when: false + when: true diff --git a/tasks.templates/t_sys_fetch_directory.yaml b/tasks.templates/t_sys_fetch_directory.yaml index f74c8f2..797ec5c 100644 --- a/tasks.templates/t_sys_fetch_directory.yaml +++ b/tasks.templates/t_sys_fetch_directory.yaml @@ -14,6 +14,8 @@ - name: Fetches the files ansible.builtin.include_tasks: t_sys_fetch_file.yaml vars: - sourceFile: "{{ item }}" - targetFile: "../{{ targetDir }}/{{ item }}" - with_items: "{{ fileList }}" + sourceFile: "{{ fetchItem }}" + targetFile: "{{ targetDir }}/{{ fetchItem | basename }}" + loop: "{{ fileList }}" + loop_control: + loop_var: fetchItem diff --git a/tasks.templates/t_sys_fetch_file.yaml b/tasks.templates/t_sys_fetch_file.yaml index 6cea0d8..ef39f2d 100644 --- a/tasks.templates/t_sys_fetch_file.yaml +++ b/tasks.templates/t_sys_fetch_file.yaml @@ -2,9 +2,12 @@ # needed facts (variables): # - sourceFile: the full path of the remote file # - targetFile: the relative path of the backup file +- name: Display the input parameters + debug: + msg: "src: {{ sourceFile }} trg: {{ targetFile }} {{ targetFile | dirname }}/meta" - name: Ensure target directory exists ansible.builtin.file: - path: "../{{ targetFile | dirname }}/meta" + path: "{{ targetFile | dirname }}/meta" state: directory mode: "0755" recurse: true -- 2.47.2