Skip to content

Commit

Permalink
[Linux] Check vmtools_log_dir is defined before using it in check_os_…
Browse files Browse the repository at this point in the history
…fullname (#498)

Signed-off-by: Qi Zhang <qiz@vmware.com>
  • Loading branch information
keirazhang committed Sep 8, 2023
1 parent a1645b9 commit e56103a
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions linux/check_os_fullname/check_os_fullname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
when: guest_file_exists
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

0 comments on commit e56103a

Please sign in to comment.