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.
autoremove: yes
cache_valid_time: 3600
install_recommends: no
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'
state: latest
update_cache: yes
when: ansible_facts.os_family == 'Debian'
-{ 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 &&
+{ echo; echo; } | adjtimex -l &&
freq=`adjtimex -p | awk '/frequency:/ {print $2}'` &&
tick=`adjtimex -p | awk '/tick:/ {print $2}'` &&
#adjtimex -f "$freq" -t "$tick" &&
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