Skip to content

[Linux] Get installed open-vm-tools packages before uninstalling #704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions linux/open_vm_tools/uninstall_ovt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
# Parameters:
# ovt_packages: a list of open-vm-tools packages
#

- name: "Get installed packages on {{ vm_guest_os_distribution }}"
include_tasks: ../utils/get_installed_packages.yml

- name: "Set fact of installed open-vm-tools related packages"
ansible.builtin.set_fact:
installed_ovt_packages: "{{ ovt_packages | select('in', guest_installed_packages) }}"

- name: "Display open-vm-tools related packages which are installed in guest OS"
ansible.builtin.debug: var=installed_ovt_packages

# Uninstall open-vm-tools packages
- name: "Uninstall packages {{ ovt_packages }}"
ansible.builtin.command: "{{ package_uninstall_cmd }} {{ ' '.join(ovt_packages) }}"
- name: "Uninstall open-vm-tools related packages on {{ vm_guest_os_distribution }}"
ansible.builtin.command: "{{ package_uninstall_cmd }} {{ ' '.join(installed_ovt_packages) }}"
register: ovt_uninstall_result
ignore_errors: true
delegate_to: "{{ vm_guest_ip }}"

- name: "Display the packages uninstall output"
ansible.builtin.debug: var=ovt_uninstall_result
when: enable_debug | bool

- name: "Assert command is executed successfully"
ansible.builtin.assert:
that:
- ovt_uninstall_result is defined
- ovt_uninstall_result.stdout is defined
- ovt_uninstall_result.stdout
- ovt_uninstall_result.rc is defined
- ovt_uninstall_result.rc | int == 0
fail_msg: "Failed to uninstall open-vm-tools by executing command: {{ package_uninstall_cmd }} {{ ' '.join(ovt_packages) }}"
when: enable_debug

- name: "Reboot VM to make changes take effect"
include_tasks: ../utils/reboot.yml
Expand All @@ -36,7 +36,7 @@
include_tasks: check_ovt_package.yml
vars:
expected_package_state: "absent"
with_items: "{{ ovt_packages }}"
with_items: "{{ installed_ovt_packages }}"
loop_control:
loop_var: package_name

Expand Down
2 changes: 1 addition & 1 deletion linux/utils/enable_auto_login.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- name: "Set GDM config file path in {{ vm_guest_os_distribution }}"
ansible.builtin.set_fact:
dm_conf_path: "/etc/gdm/custom.conf"
when: guest_os_family == "RedHat"
when: guest_os_family in ["RedHat", "Suse"]

- name: "Set GDM config file path for Ubuntu"
ansible.builtin.set_fact:
Expand Down