From 795d793fd1000b0d51ce41341d07fd79f009fd6e Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Thu, 7 Sep 2023 15:26:08 +0800 Subject: [PATCH 1/2] Check vmtools_log_dir is defined before using Signed-off-by: Qi Zhang --- linux/check_os_fullname/check_os_fullname.yml | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/linux/check_os_fullname/check_os_fullname.yml b/linux/check_os_fullname/check_os_fullname.yml index 017af8142..a4e9cff4f 100644 --- a/linux/check_os_fullname/check_os_fullname.yml +++ b/linux/check_os_fullname/check_os_fullname.yml @@ -102,29 +102,34 @@ - name: "Test rescue" include_tasks: ../../common/test_rescue.yml always: - - name: "Get VMware Tools log directory stat info" - include_tasks: ../utils/get_file_stat_info.yml - vars: - guest_file_path: "{{ vmtools_log_dir }}" - - name: "Collect VMware Tools logs" + when: + - vmtools_log_dir is defined + - vmtools_log_dir block: - - name: "Archive VMware Tools debug logs" - community.general.archive: - path: "{{ vmtools_log_dir }}" - dest: "{{ vmtools_log_dir }}.tgz" - mode: "0644" - delegate_to: "{{ vm_guest_ip }}" - register: archive_vmtools_logs - - - name: "Fetch VMware Tools debug logs" - include_tasks: ../utils/fetch_file.yml + - name: "Get VMware Tools log directory stat info" + include_tasks: ../utils/get_file_stat_info.yml vars: - fetch_file_src_path: "{{ vmtools_log_dir }}.tgz" - fetch_file_dst_path: "{{ current_test_log_folder }}/" - fetch_file_ignore_errors: true - when: - - archive_vmtools_logs is defined - - archive_vmtools_logs.changed is defined - - archive_vmtools_logs.changed - when: guest_file_exists + guest_file_path: "{{ vmtools_log_dir }}" + + - name: "Collect VMware Tools logs" + block: + - name: "Archive VMware Tools debug logs" + community.general.archive: + path: "{{ vmtools_log_dir }}" + dest: "{{ vmtools_log_dir }}.tgz" + mode: "0644" + delegate_to: "{{ vm_guest_ip }}" + register: archive_vmtools_logs + + - name: "Fetch VMware Tools debug logs" + include_tasks: ../utils/fetch_file.yml + vars: + fetch_file_src_path: "{{ vmtools_log_dir }}.tgz" + fetch_file_dst_path: "{{ current_test_log_folder }}/" + fetch_file_ignore_errors: true + when: + - archive_vmtools_logs is defined + - archive_vmtools_logs.changed is defined + - archive_vmtools_logs.changed + when: guest_file_exists From 3ccfc01518821006d07344a63669afa480a1501d Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Fri, 8 Sep 2023 09:54:27 +0800 Subject: [PATCH 2/2] Move up 'when' before 'block' Signed-off-by: Qi Zhang --- linux/check_os_fullname/check_os_fullname.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/check_os_fullname/check_os_fullname.yml b/linux/check_os_fullname/check_os_fullname.yml index a4e9cff4f..f470cd054 100644 --- a/linux/check_os_fullname/check_os_fullname.yml +++ b/linux/check_os_fullname/check_os_fullname.yml @@ -113,6 +113,7 @@ guest_file_path: "{{ vmtools_log_dir }}" - name: "Collect VMware Tools logs" + when: guest_file_exists block: - name: "Archive VMware Tools debug logs" community.general.archive: @@ -132,4 +133,3 @@ - archive_vmtools_logs is defined - archive_vmtools_logs.changed is defined - archive_vmtools_logs.changed - when: guest_file_exists