Add chrony as timesync service
This commit is contained in:
parent
3efbbd95c8
commit
cb9f61ccf7
|
@ -11,3 +11,9 @@
|
|||
state: restarted
|
||||
|
||||
|
||||
- name: Restart Chrony
|
||||
service:
|
||||
name: '{{ chrony_service_name }}'
|
||||
state: restarted
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- name: Check selected timesync daemon
|
||||
fail:
|
||||
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
|
||||
|
@ -22,7 +22,6 @@
|
|||
when: timesync_servers|default(False) == False and timesync_pools|default(False) == False
|
||||
|
||||
|
||||
|
||||
- name: Include OS dependent variables
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
|
|
24
roles/timesync-enabled/tasks/timesync_chrony.yml
Normal file
24
roles/timesync-enabled/tasks/timesync_chrony.yml
Normal 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
|
||||
|
||||
|
19
roles/timesync-enabled/templates/etc/chrony/chrony.conf.j2
Normal file
19
roles/timesync-enabled/templates/etc/chrony/chrony.conf.j2
Normal 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
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
---
|
||||
chrony_service_name: chrony
|
||||
|
||||
ntp_service_name: ntp
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
---
|
||||
chrony_service_name: chronyd
|
||||
|
||||
ntp_service_name: ntpd
|
||||
|
||||
|
|
Loading…
Reference in a new issue