2016-08-25 13:19:51 +02:00
|
|
|
---
|
2017-11-04 23:54:53 +01:00
|
|
|
# Hosts running Ubuntu 16.04 and Debian 9 use the 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
|
|
|
tags: packages
|
|
|
|
|
|
|
|
- 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
|
|
|
tags: packages
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2:
|