Add chrony as timesync service

This commit is contained in:
Sven Velt 2020-12-02 22:14:58 +01:00
parent 3efbbd95c8
commit cb9f61ccf7
6 changed files with 54 additions and 2 deletions

View file

@ -11,3 +11,9 @@
state: restarted state: restarted
- name: Restart Chrony
service:
name: '{{ chrony_service_name }}'
state: restarted

View file

@ -2,7 +2,7 @@
- name: Check selected timesync daemon - name: Check selected timesync daemon
fail: fail:
fail_msg: "{{ timesync_daemon|default('No daemon') }} not supported" fail_msg: "{{ timesync_daemon|default('No daemon') }} not supported"
when: timesync_daemon not in [ "ntp", "timesyncd" ] when: timesync_daemon not in [ "chrony", "ntp", "timesyncd" ]
- name: Include each network variables if there is no host variable - name: Include each network variables if there is no host variable
@ -22,7 +22,6 @@
when: timesync_servers|default(False) == False and timesync_pools|default(False) == False when: timesync_servers|default(False) == False and timesync_pools|default(False) == False
- name: Include OS dependent variables - name: Include OS dependent variables
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:

View file

@ -0,0 +1,24 @@
---
- name: Install Chrony
package:
name: chrony
state: latest
- name: Template chrony.conf
template:
src: etc/chrony/chrony.conf.j2
dest: /etc/chrony/chrony.conf
owner: root
group: root
mode: 0644
backup: yes
notify: Restart Chrony
- name: Enable Chrony daemon
service:
name: "{{ chrony_service_name }}"
enabled: True

View file

@ -0,0 +1,19 @@
# NTP servers
{% for pool in timesync_pools|default([]) %}pool {{ pool }} iburst
{% endfor %}
# NTP servers
{% for server in timesync_servers|default([]) %}server {{ server }} iburst
{% endfor %}
keyfile /etc/chrony/chrony.keys
generatecommandkey
commandkey 1
###initstepslew 10 0.de.pool.ntp.org
driftfile /var/lib/chrony/chrony.drift
rtconutc
rtcsync

View file

@ -1,3 +1,5 @@
--- ---
chrony_service_name: chrony
ntp_service_name: ntp ntp_service_name: ntp

View file

@ -1,3 +1,5 @@
--- ---
chrony_service_name: chronyd
ntp_service_name: ntpd ntp_service_name: ntpd