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'
#! /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