Skip to content

Commit

Permalink
Set guest_os_with_gui=false when no display manager
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Zhang <[email protected]>
  • Loading branch information
keirazhang committed Aug 4, 2023
1 parent 1b825d5 commit 0963592
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
10 changes: 9 additions & 1 deletion linux/utils/check_guest_os_gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@
- display_manager_status.rc == 0
- display_manager_status.stdout_lines is defined
- display_manager_status.stdout_lines | length > 0

# If systemctl status display-manager.service error code is 4, it means
# the service doesn't exist, so guest OS doesn't have desktop
- name: "Set fact of guest OS having no desktop environment"
ansible.builtin.set_fact:
guest_os_with_gui: false
when: >
(display_manager_status.rc is undefined or
display_manager_status.rc == 4)
when:
- guest_os_with_gui | bool
- guest_os_ansible_distribution != 'Astra Linux (Orel)'


- name: "Set fact of guest OS display manager for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
guest_os_display_manager: "fly-dm"
Expand Down
41 changes: 19 additions & 22 deletions linux/utils/set_ovt_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,35 @@
---
# Set the fact of open-vm-tools packages, processes and services
#
- name: "Initialize the fact of open-vm-tools packages, processe and service"
- name: "Set fact of open-vm-tools service for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
ovt_packages: ["open-vm-tools"]
ovt_processes: [{"uid": "root", "cmd":"vmtoolsd"}]
ovt_service: |-
{%- if guest_os_family == 'FreeBSD' -%}vmware-guestd
{%- elif guest_os_family in ['Debian', 'Astra Linux (Orel)'] -%}open-vm-tools
{%- else -%}vmtoolsd
{%- endif -%}
- name: "Update the fact of ovt_packages for FreeBSD without GUI"
- name: "Set facts of open-vm-tools packages and processes for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
ovt_packages: ["open-vm-tools-nox11"]
when:
- guest_os_ansible_distribution == "FreeBSD"
- guest_os_with_gui is undefined or not guest_os_with_gui
ovt_packages: |-
{%- if guest_os_family == 'FreeBSD' -%}["open-vm-tools-nox11"]
{%- elif guest_os_family == "Suse" -%}["open-vm-tools", "libvmtools0"]
{%- else -%}["open-vm-tools"]
{%- endif -%}
ovt_processes:
- {"uid": "root", "cmd":"vmtoolsd"}
when: guest_os_with_gui is undefined or not guest_os_with_gui

- name: "Add extra package libvmtools0 for {{ guest_os_ansible_distribution }}"
- name: "Set facts of open-vm-tools packages and processes for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
ovt_packages: "{{ ovt_packages | union(['libvmtools0']) }}"
when: guest_os_family == "Suse"

- name: "Update facts of open-vm-tools packages and processes"
ovt_packages: |-
{%- if guest_os_family == 'FreeBSD' -%}["open-vm-tools"]
{%- elif guest_os_family == "Suse" -%}["open-vm-tools", "open-vm-tools-desktop", "libvmtools0"]
{%- else -%}["open-vm-tools", "open-vm-tools-desktop"]
{%- endif -%}
ovt_processes:
- {"uid": "root", "cmd":"vmtoolsd"}
- {'uid':'vmware', 'cmd':'vmtoolsd -n vmusr'}
when:
- guest_os_with_gui is defined
- guest_os_with_gui
block:
- name: "Update the fact of open-vm-tools packages for {{ guest_os_family }}"
ansible.builtin.set_fact:
ovt_packages: "{{ ovt_packages | union(['open-vm-tools-desktop']) }}"
when: guest_os_family != "FreeBSD"

- name: "Update the fact of open-vm-tools processes for guest OS with desktop"
ansible.builtin.set_fact:
ovt_processes: "{{ ovt_processes | union([{'uid':'vmware', 'cmd':'vmtoolsd -n vmusr'}]) }}"

0 comments on commit 0963592

Please sign in to comment.