summaryrefslogtreecommitdiff
path: root/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/core/ntp/tasks/Debian_systemd-timesyncd.yml')
-rw-r--r--roles/core/ntp/tasks/Debian_systemd-timesyncd.yml18
1 files changed, 18 insertions, 0 deletions
diff --git a/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml b/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml
new file mode 100644
index 00000000..20a5f379
--- /dev/null
+++ b/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml
@@ -0,0 +1,18 @@
+---
+- name: set ntp servers
+ when:
+ - ntp_client is defined
+ - "'servers' in ntp_client"
+ lineinfile:
+ path: /etc/systemd/timesyncd.conf
+ regexp: '^#?NTP='
+ line: "NTP={{ ntp_client.servers | map(attribute='name') | join(' ') }}"
+ notify: restart systemd-timesyncd
+
+- name: un-set ntp servers
+ when: "ntp_client is not defined or 'servers' not in ntp_client"
+ lineinfile:
+ path: /etc/systemd/timesyncd.conf
+ regexp: '^#?NTP='
+ line: "#NTP="
+ notify: restart systemd-timesyncd