summaryrefslogtreecommitdiffstats
path: root/roles/common/tasks/ntp.yml
blob: 60ffef973e5cbaa5092b6518b13670728258b55f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
- name: Install/Remove ntp
  # TODO bullseye: install new package 'systemd-timesyncd'
  apt: pkg=ntp state={{ state }} purge=yes
  vars:
    state: "{{ ('NTP_master' in group_names) | ternary('present', 'absent') }}"

- name: Create /etc/systemd/timesyncd.conf.d
  file: path=/etc/systemd/timesyncd.conf.d
        state=directory
        owner=root group=root
        mode=0755
  when: "'NTP_master' not in group_names"

- name: Configure ntp
  template: src=etc/{{ conf }}.j2
            dest=/etc/{{ conf }}
            owner=root group=root
            mode=0644
  vars:
    conf: "{{ ('NTP_master' in group_names) | ternary('ntp.conf', 'systemd/timesyncd.conf.d/fripost.conf') }}"
    service: "{{ ('NTP_master' in group_names) | ternary('ntp', 'systemd-timesyncd') }}"
  notify:
    - Restart {{ service }}

- meta: flush_handlers

- name: Start and enable ntp
  service: name={{ service }}.service state=started enabled=true
  vars:
    service: "{{ ('NTP_master' in group_names) | ternary('ntp', 'systemd-timesyncd') }}"