]> git.phdru.name Git - ansible.git/commitdiff
Feat(adjtimex): Convert script `adjtimex.sh` to a template
authorOleg Broytman <phd@phdru.name>
Sun, 4 Aug 2019 18:49:27 +0000 (21:49 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 4 Aug 2019 18:50:33 +0000 (21:50 +0300)
playbooks/debian/roles/adjtimex/tasks/main.yml
playbooks/debian/roles/adjtimex/templates/adjtimex.sh [new file with mode: 0755]

index 0585334a346d0c4ed16395e6a801367c2831e468..fb720c71c7cbc3010b6cc719d3ce3d15c7b35def 100644 (file)
@@ -1,6 +1,7 @@
 - name: Copy the script adjtimex.sh
-  copy:
-    src: ~/admin/prog/adjtimex.sh
+  become: true
+  template:
+    src: adjtimex.sh
     dest: /usr/local/sbin/adjtimex.sh
     owner: root
     group: root
diff --git a/playbooks/debian/roles/adjtimex/templates/adjtimex.sh b/playbooks/debian/roles/adjtimex/templates/adjtimex.sh
new file mode 100755 (executable)
index 0000000..1a4d1c1
--- /dev/null
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.pool.ntp.org &&
+adjtimex -r --adjust &&
+
+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-debian &&
+hwclock --systohc &&
+{ echo; echo; } | adjtimex -h ru.pool.ntp.org