---

- assert:
    that: ansible_os_family in [ 'Debian', 'OpenBSD' ]

- name: apt install ntpd
  when: ansible_pkg_mgr == 'apt'
  apt:
    name: ntp
    state: present
    update_cache: yes
    cache_valid_time: 3600

- name: Configure ntpd
  template:
    src: ntpd.conf.j2
    dest: '{{ ntpd_conf[ansible_os_family] }}'
    owner: root
    group: 0
    mode: 0o0644
  notify:
  - Restart ntpd

- name: Enable ntpd
  service:
    name: '{{ ntpd_service[ansible_os_family] }}'
    enabled: yes
    state: started
