summaryrefslogtreecommitdiff
path: root/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml
blob: 20a5f379c927ea64a965e5137e03efe1b142998e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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