]> git.phdru.name Git - ansible.git/commitdiff
Fix(adjtimex): Call `adjtimex` without `-h`
authorOleg Broytman <phd@phdru.name>
Sat, 14 Dec 2019 15:02:52 +0000 (18:02 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 16 Dec 2019 09:27:31 +0000 (12:27 +0300)
In debian 10 `adjtimex` is buggy
(see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944867)
so we have to run it without `-h`.
Ok, `adjtimex -l` + `ntpdate` + `hwclock` is enough.

Fix Debian package name.

playbooks/roles/adjtimex/tasks/main.yml
playbooks/roles/adjtimex/templates/adjtimex.sh

index a7864a80c1c3547ba9abd68882c11331c3e03c44..ba1f74452df70f6d3b76e2840a3356d7317eaad6 100644 (file)
@@ -5,7 +5,7 @@
     autoremove: yes
     cache_valid_time: 3600
     install_recommends: no
-    name: ['adjtimex', 'ntpdate-debian']
+    name: ['adjtimex', 'ntpdate']
     state: latest
     update_cache: yes
   when: ansible_facts.os_family == 'Debian'
index 98e11353b8c61ed339d74c9c7656df2045b5e3c4..4ee2a4b1676dc1a776bb44ac7463f713402bec87 100755 (executable)
@@ -1,15 +1,24 @@
 #! /bin/sh
 
-{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.pool.ntp.org &&
+# Stole some ideas from
+# http://support.ntp.org/bin/view/Support/ManualCalibration
+
+{ echo; echo; } | adjtimex -l &&
+ntpdate{% if ansible_facts.os_family == 'Debian' %}-debian{% endif %} &&
+{ echo; echo; } | adjtimex -l &&
+
+hwclock --systohc &&
+{ echo; echo; } | adjtimex -l &&
+hwclock --hctosys &&
+
+{ echo; echo; } | adjtimex -l &&
 adjtimex -r --adjust &&
+{ echo; echo; } | adjtimex -l &&
 
 freq=`adjtimex -p | awk '/frequency:/ {print $2}'` &&
 tick=`adjtimex -p | awk '/tick:/ {print $2}'` &&
 #adjtimex -f "$freq" -t "$tick" &&
 
-sed -i "s/^FREQ=.\+$/FREQ=$freq/" /etc/default/adjtimex &&
-sed -i "s/^TICK=.\+$/TICK=$tick/" /etc/default/adjtimex &&
-
-ntpdate{% if ansible_facts.os_family == 'Debian' %}-debian{% endif %} &&
-hwclock --systohc &&
-{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.pool.ntp.org &&
+tail -2 /etc/default/adjtimex &&
+sed -i -e "s/^FREQ=.\+$/FREQ=$freq/" -e "s/^TICK=.\+$/TICK=$tick/" /etc/default/adjtimex &&
+exec tail -2 /etc/default/adjtimex