From: David Galloway Date: Tue, 10 Apr 2018 13:53:37 +0000 (-0400) Subject: tools: Force time synchronization in FOG images X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0ae62b0498ef32642aff52033ec4c2ea2d38926d;p=ceph-cm-ansible.git tools: Force time synchronization in FOG images Signed-off-by: David Galloway --- diff --git a/tools/prep-fog-capture.yml b/tools/prep-fog-capture.yml index ea29ef2..86bc241 100644 --- a/tools/prep-fog-capture.yml +++ b/tools/prep-fog-capture.yml @@ -68,3 +68,31 @@ path: /etc/rhsm/facts/katello.facts state: absent when: '"Red Hat" in ansible_lsb.description' + + - set_fact: + ntp_service: ntp + when: ansible_os_family == "Debian" + + - set_fact: + ntp_service: ntpd + when: ansible_os_family == "RedHat" + + - name: "Stop {{ ntp_service }} service" + service: + name: "{{ ntp_service }}" + state: stopped + + # The theory here is although we do have the ntp service running on boot, + # if the time is off, it slowly drifts back in sync. Since our testnodes + # are ephemeral, they don't ever have enough time to correctly drift + # back to the correct time. So we'll force it in the captured OS images. + - name: Force time synchronization using stepping + command: "ntpdate -b {{ ntp_servers|join(' ') }}" + + - name: "Start {{ ntp_service }} again" + service: + name: "{{ ntp_service }}" + state: started + + - name: Sync the hardware clock + command: "hwclock --systohc"