Add busybox' ntpd as timesync server (e.g. Alpine)

This commit is contained in:
Sven Velt 2020-12-02 22:18:36 +01:00
parent cb9f61ccf7
commit 6aa7cae716
3 changed files with 35 additions and 1 deletions

View file

@ -2,7 +2,7 @@
- name: Check selected timesync daemon
fail:
fail_msg: "{{ timesync_daemon|default('No daemon') }} not supported"
when: timesync_daemon not in [ "chrony", "ntp", "timesyncd" ]
when: timesync_daemon not in [ "busybox-ntp", "chrony", "ntp", "timesyncd" ]
- name: Include each network variables if there is no host variable

View file

@ -0,0 +1,25 @@
---
- name: Template ntp.conf
template:
src: etc/busybox-ntp.conf.j2
dest: /etc/ntp.conf
owner: root
group: root
mode: 0644
backup: yes
notify: Restart NTP
- name: Remove server from command line
replace:
path: /etc/conf.d/ntpd
regexp: '\s?-p\s*[^ "]+'
replace: ''
- name: Enable NTP daemon
service:
name: '{{ ntp_service_name }}'
enabled: True

View file

@ -0,0 +1,9 @@
### {{ ansible_managed }}
# /etc/ntp.conf for Busybox ntpd
{% for server in timesync_pools|default([]) %}server {{ server }}
{% endfor %}
{% for server in timesync_servers|default([]) %}server {{ server }}
{% endfor %}