From 0ae62b0498ef32642aff52033ec4c2ea2d38926d Mon Sep 17 00:00:00 2001 From: David Galloway Date: Tue, 10 Apr 2018 09:53:37 -0400 Subject: [PATCH] tools: Force time synchronization in FOG images Signed-off-by: David Galloway --- tools/prep-fog-capture.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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" -- 2.39.5