2017-11-30 14:28:28 +00:00
|
|
|
---
|
|
|
|
### Create groups
|
|
|
|
- hosts: all
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- group_by:
|
|
|
|
key: "virt_{{ ansible_virtualization_role }}"
|
|
|
|
|
|
|
|
|
|
|
|
- hosts: virt_guest
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- group_by:
|
|
|
|
key: "virtguest_{{ ansible_virtualization_type }}"
|
|
|
|
|
|
|
|
|
|
|
|
# Debugging only
|
2020-12-02 21:44:01 +00:00
|
|
|
- hosts: all
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
tasks:
|
2020-12-02 21:44:01 +00:00
|
|
|
- set_fact:
|
|
|
|
timesync_force: timesync_servers is defined or timesync_pools is defined
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
### Hosts: Install/Configure NTP
|
|
|
|
- hosts:
|
|
|
|
- virt_NA
|
|
|
|
- virt_host
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
roles:
|
|
|
|
- timesync-enabled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Container-Guests: Disable timesync!
|
|
|
|
- hosts:
|
|
|
|
- virtguest_docker
|
|
|
|
- virtguest_openvz
|
|
|
|
- virtguest_linuxvserver
|
|
|
|
- virtguest_lxc
|
|
|
|
- virtguest_lxc-libvirt
|
|
|
|
- virtguest_rkt
|
|
|
|
- virtguest_uml
|
|
|
|
- virtguest_systemd-nspawn
|
|
|
|
- virtguest_container-other
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
roles:
|
2020-12-02 21:41:38 +00:00
|
|
|
- role: timesync-disabled
|
|
|
|
when: not timesync_development|default(False)
|
|
|
|
- role: timesync-enabled
|
|
|
|
when: timesync_development|default(False)
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### KVM-Guests:
|
|
|
|
# https://s19n.net/articles/2011/kvm_clock.html
|
|
|
|
- hosts:
|
|
|
|
- virtguest_kvm
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
pre_tasks:
|
|
|
|
|
|
|
|
- command: cat /sys/devices/system/clocksource/clocksource0/current_clocksource
|
|
|
|
register: clocksource
|
|
|
|
changed_when: False
|
|
|
|
|
|
|
|
roles:
|
2020-12-02 21:44:40 +00:00
|
|
|
- role: timesync-disabled
|
|
|
|
when: clocksource.stdout == "kvm-clock" and not timesync_force
|
|
|
|
- role: timesync-enabled
|
|
|
|
when: clocksource.stdout != "kvm-clock" or timesync_force
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### VMware-Guests:
|
|
|
|
# Open-VM-Tools: https://blogs.vmware.com/vsphere/2015/09/open-vm-tools-ovt-the-future-of-vmware-tools-for-linux.html
|
|
|
|
- hosts:
|
|
|
|
- virtguest_VMware
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
pre_tasks:
|
2020-12-02 21:44:01 +00:00
|
|
|
- name: Check for vmware-toolbox-cmd
|
|
|
|
stat:
|
|
|
|
path: /usr/bin/vmware-toolbox-cmd
|
|
|
|
register: vmwtbcmd
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
- name: Install Open-VM-Tools
|
|
|
|
package:
|
|
|
|
name: open-vm-tools
|
|
|
|
state: present
|
2020-12-02 21:44:01 +00:00
|
|
|
when: vmwtbcmd.stat.exists == False
|
2017-11-30 14:28:28 +00:00
|
|
|
|
2020-12-02 21:44:01 +00:00
|
|
|
- name: Get timesync status
|
|
|
|
shell: 'vmware-toolbox-cmd timesync status || true'
|
2017-11-30 14:28:28 +00:00
|
|
|
changed_when: False
|
|
|
|
register: vmwtbcmd_timesync
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- vmwtbcmd_timesync.stdout in ["Enabled", "Disabled"]
|
|
|
|
|
|
|
|
roles:
|
2020-12-02 21:44:01 +00:00
|
|
|
- role: timesync-disabled
|
|
|
|
when: vmwtbcmd_timesync.stdout == "Enabled" and not timesync_force
|
|
|
|
- role: timesync-enabled
|
|
|
|
when: vmwtbcmd_timesync.stdout == "Disabled" or timesync_force
|
2017-11-30 14:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Xen-Guests: https://wiki.xen.org/wiki/Xen_FAQ_DomU#How_can_i_synchronize_a_dom0_clock.3F
|
|
|
|
- hosts:
|
|
|
|
- virtguest_xen
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
pre_tasks:
|
2020-12-02 21:44:31 +00:00
|
|
|
- shell: 'cat /proc/sys/xen/independent_wallclock || echo 1'
|
2017-11-30 14:28:28 +00:00
|
|
|
changed_when: False
|
|
|
|
register: independent_wallclock
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- independent_wallclock.stdout == "1"
|
|
|
|
|
|
|
|
roles:
|
|
|
|
- timesync-enabled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### FIXME
|
|
|
|
- hosts:
|
|
|
|
- virtguest_RHEV
|
|
|
|
- virtguest_virtualbox
|
|
|
|
- virtguest_VirtualPC
|
|
|
|
- virtguest_parallels
|
|
|
|
- virtguest_powervm_lx86
|
|
|
|
- "virtguest_PR/SM_LPAR"
|
|
|
|
- virtguest_ibm_systemz
|
|
|
|
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- fail:
|
|
|
|
msg: "Not yet implemented"
|
|
|
|
|
|
|
|
|