|
5 | 5 | # Parameters:
|
6 | 6 | # ovt_packages: a list of open-vm-tools packages
|
7 | 7 | #
|
| 8 | + |
| 9 | +- name: "Get installed packages on {{ vm_guest_os_distribution }}" |
| 10 | + include_tasks: ../utils/get_installed_packages.yml |
| 11 | + |
| 12 | +- name: "Set fact of installed open-vm-tools related packages" |
| 13 | + ansible.builtin.set_fact: |
| 14 | + installed_ovt_packages: "{{ ovt_packages | select('in', guest_installed_packages) }}" |
| 15 | + |
| 16 | +- name: "Display open-vm-tools related packages which are installed in guest OS" |
| 17 | + ansible.builtin.debug: var=installed_ovt_packages |
| 18 | + |
8 | 19 | # Uninstall open-vm-tools packages
|
9 |
| -- name: "Uninstall packages {{ ovt_packages }}" |
10 |
| - ansible.builtin.command: "{{ package_uninstall_cmd }} {{ ' '.join(ovt_packages) }}" |
| 20 | +- name: "Uninstall open-vm-tools related packages on {{ vm_guest_os_distribution }}" |
| 21 | + ansible.builtin.command: "{{ package_uninstall_cmd }} {{ ' '.join(installed_ovt_packages) }}" |
11 | 22 | register: ovt_uninstall_result
|
12 |
| - ignore_errors: true |
13 | 23 | delegate_to: "{{ vm_guest_ip }}"
|
14 | 24 |
|
15 | 25 | - name: "Display the packages uninstall output"
|
16 | 26 | ansible.builtin.debug: var=ovt_uninstall_result
|
17 |
| - when: enable_debug | bool |
18 |
| - |
19 |
| -- name: "Assert command is executed successfully" |
20 |
| - ansible.builtin.assert: |
21 |
| - that: |
22 |
| - - ovt_uninstall_result is defined |
23 |
| - - ovt_uninstall_result.stdout is defined |
24 |
| - - ovt_uninstall_result.stdout |
25 |
| - - ovt_uninstall_result.rc is defined |
26 |
| - - ovt_uninstall_result.rc | int == 0 |
27 |
| - fail_msg: "Failed to uninstall open-vm-tools by executing command: {{ package_uninstall_cmd }} {{ ' '.join(ovt_packages) }}" |
| 27 | + when: enable_debug |
28 | 28 |
|
29 | 29 | - name: "Reboot VM to make changes take effect"
|
30 | 30 | include_tasks: ../utils/reboot.yml
|
|
36 | 36 | include_tasks: check_ovt_package.yml
|
37 | 37 | vars:
|
38 | 38 | expected_package_state: "absent"
|
39 |
| - with_items: "{{ ovt_packages }}" |
| 39 | + with_items: "{{ installed_ovt_packages }}" |
40 | 40 | loop_control:
|
41 | 41 | loop_var: package_name
|
42 | 42 |
|
|
0 commit comments