Skip to content
Snippets Groups Projects
Commit 446c8848 authored by Jörg Sachse's avatar Jörg Sachse
Browse files

test: increase Molecule test coverage by checking for specific ESXi hypervisor...

test: increase Molecule test coverage by checking for specific ESXi hypervisor only on tasks that absolutely need it
parent eadf1971
No related branches found
No related tags found
Loading
Pipeline #7368 failed
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
- name: NTP-Client - name: NTP-Client
ansible.builtin.import_tasks: "migrate_ntpd_to_esxi_timesync.yml" ansible.builtin.import_tasks: "migrate_ntpd_to_esxi_timesync.yml"
when: # implicit AND when passing a list # We want to keep Chrony/NTPd von physical machines, so this will only ever
- ansible_facts.virtualization_role == "guest" # need to be executed on VMs. Physical hosts will have
- ansible_facts.virtualization_type == "VMware" # ansible_facts.virtualization_role: "host"
# in their facts.
when: ansible_facts.virtualization_role == "guest"
tags: [ntp, ntpd, time] tags: [ntp, ntpd, time]
- name: Systempakete installieren - name: Systempakete installieren
......
...@@ -27,35 +27,45 @@ ...@@ -27,35 +27,45 @@
- "/etc/ntp.conf" - "/etc/ntp.conf"
- "/etc/ntpsec/ntp.conf" - "/etc/ntpsec/ntp.conf"
# details can be found at sdvgubs10 project, issue #2 - name: configure ESXi based time synchronisation
# https://git.slub-dresden.de/slub-referat-2-4/sdvgubs10 when: ansible_facts.virtualization_type == "VMware"
- name: make sure open-vm-tools are installed # This whole set of tasks is skipped in Molecule tests, because they
ansible.builtin.package: # usually don't run on ESXi hypervisors here at SLUB during local tests or
name: "open-vm-tools" # in CI. It is indeed tempting to check for other hypervisors here, but it
state: latest # doesn't make any sense, because the tasks are strictly bound to technolo-
# gies that work ONLY with ESXi, so using something like:
# ansible_facts.virtualization_type == "virtualbox"
# will not save you. Just don't.
block:
# details can be found at sdvgubs10 project, issue #2
# https://git.slub-dresden.de/slub-referat-2-4/sdvgubs10
- name: make sure open-vm-tools are installed
ansible.builtin.package:
name: "open-vm-tools"
state: latest
- name: make sure that 'vmware-toolbox-cmd' exists - name: make sure that 'vmware-toolbox-cmd' exists
ansible.builtin.stat: ansible.builtin.stat:
path: "/usr/bin/vmware-toolbox-cmd" path: "/usr/bin/vmware-toolbox-cmd"
follow: true follow: true
register: vmtools register: vmtools
- name: get current ESXi timesync status - name: get current ESXi timesync status
ansible.builtin.command: "/usr/bin/vmware-toolbox-cmd timesync status" ansible.builtin.command: "/usr/bin/vmware-toolbox-cmd timesync status"
when: when:
- vmtools.stat.exists - vmtools.stat.exists
- vmtools.stat.isreg - vmtools.stat.isreg
- vmtools.stat.xusr - vmtools.stat.xusr
register: timesync register: timesync
failed_when: ( timesync.rc != 0 ) and ( timesync.rc != 69 ) failed_when: ( timesync.rc != 0 ) and ( timesync.rc != 69 )
changed_when: false changed_when: false
- name: enable ESXi timesync if necessary - name: enable ESXi timesync if necessary
ansible.builtin.command: "/usr/bin/vmware-toolbox-cmd timesync enable" ansible.builtin.command: "/usr/bin/vmware-toolbox-cmd timesync enable"
when: when:
- ( timesync.stdout not in "Aktiviert" ) or - ( timesync.stdout not in "Aktiviert" ) or
( timesync.stdout not in "Enabled" ) ( timesync.stdout not in "Enabled" )
- vmtools.stat.exists - vmtools.stat.exists
- vmtools.stat.isreg - vmtools.stat.isreg
- vmtools.stat.xusr - vmtools.stat.xusr
changed_when: false changed_when: false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment