summaryrefslogtreecommitdiff
path: root/roles/core/ntp/tasks/Debian_systemd-timesyncd.yml
blob: ebbe51b49492a36302259e1939dcfcf3c91be143 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
- name: make sure ntp_server is not defined
  assert:
    that: ntp_server is not defined
    msg: "systemd-timesyncd can not be used as a NTP server"

- 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