2016-08-25 13:19:51 +02:00
|
|
|
---
|
2019-07-01 23:12:32 +02:00
|
|
|
# Hosts running Ubuntu 16.04+ and Debian 9+ use systemd init system and should
|
2016-08-25 13:19:51 +02:00
|
|
|
# use timedatectl as a network time client instead of the standalone ntp client.
|
|
|
|
# Earlier versions of those distros should use the ntp/ntpd package.
|
|
|
|
|
|
|
|
- name: Set timezone
|
|
|
|
when: timezone is defined and ansible_service_mgr == 'systemd'
|
|
|
|
command: /usr/bin/timedatectl set-timezone {{ timezone }}
|
|
|
|
tags: timezone
|
|
|
|
|
2017-11-02 17:55:20 +01:00
|
|
|
- name: Start and enable systemd's NTP client
|
2016-08-25 13:19:51 +02:00
|
|
|
when: ansible_service_mgr == 'systemd'
|
2017-11-02 17:55:20 +01:00
|
|
|
systemd: name=systemd-timesyncd state=started enabled=yes
|
2016-08-25 13:19:51 +02:00
|
|
|
|
|
|
|
- name: Uninstall ntp on modern Ubuntu/Debian
|
|
|
|
apt: name=ntp state=absent update_cache=yes
|
2017-11-05 00:19:28 +01:00
|
|
|
when: ansible_service_mgr == 'systemd'
|
2016-08-25 13:19:51 +02:00
|
|
|
|
|
|
|
- name: Install ntp on old Ubuntu/Debian
|
|
|
|
apt: name=ntp state=present update_cache=yes
|
2017-11-05 00:41:38 +01:00
|
|
|
when: ansible_service_mgr != 'systemd'
|
2016-08-25 13:19:51 +02:00
|
|
|
|
|
|
|
# vim: set ts=2 sw=2:
|