diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-11-27 23:26:04 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-11-28 00:52:04 +0100 |
commit | 221413244a408cfe27c894a8aef4c68a38348b43 (patch) | |
tree | a4eb0760f37e2910e40b13173f2e611bbd0ae9b4 /roles/core/ntp/tasks | |
parent | move chrony role to core/ntp (WIP) (diff) |
core/ntp role add systemd-timesyncd and openntpd
Diffstat (limited to 'roles/core/ntp/tasks')
-rw-r--r-- | roles/core/ntp/tasks/openntpd.yml | 11 | ||||
-rw-r--r-- | roles/core/ntp/tasks/systemd-timesyncd.yml | 18 |
2 files changed, 29 insertions, 0 deletions
diff --git a/roles/core/ntp/tasks/openntpd.yml b/roles/core/ntp/tasks/openntpd.yml new file mode 100644 index 00000000..76f62646 --- /dev/null +++ b/roles/core/ntp/tasks/openntpd.yml @@ -0,0 +1,11 @@ +--- +- name: install openntpd + apt: + name: openntpd + state: present + +- name: install openntpd configuration + template: + src: openntpd.conf.j2 + dest: /etc/openntpd/ntpd.conf + notify: restart openntpd 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 |