From 221413244a408cfe27c894a8aef4c68a38348b43 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 27 Nov 2020 23:26:04 +0100 Subject: core/ntp role add systemd-timesyncd and openntpd --- roles/core/ntp/tasks/systemd-timesyncd.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 roles/core/ntp/tasks/systemd-timesyncd.yml (limited to 'roles/core/ntp/tasks/systemd-timesyncd.yml') diff --git a/roles/core/ntp/tasks/systemd-timesyncd.yml b/roles/core/ntp/tasks/systemd-timesyncd.yml new file mode 100644 index 00000000..20a5f379 --- /dev/null +++ b/roles/core/ntp/tasks/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 -- cgit v1.2.3