--- - name: "[Alpine] Install package: chrony" apk: name: chrony state: present when: - ansible_distribution == "Alpine" - system.useNTP is true notify: Restart chrony - name: "[OpenRC] Enable and start service: chronyd" service: name: chronyd enabled: yes state: started when: - ansible_service_mgr == "openrc" - system.useNTP is true ignore_errors: true - name: "[OpenRC] Disable and stop service: chronyd" service: name: chronyd enabled: no state: stopprf when: - ansible_service_mgr == "openrc" - system.useNTP is false ignore_errors: true - name: "[Alpine] Remove package: chrony" apk: name: chrony state: absent when: - ansible_distribution == "Alpine" - system.useNTP is false - name: "[systemd] Enable and start service: systemd-timesyncd" systemd: name: systemd-timesyncd state: started enabled: yes when: - ansible_service_mgr == "systemd"