Small improvemnts, distribution independent

This commit is contained in:
Sven Velt 2020-12-02 21:55:22 +01:00
parent 89c7381ef2
commit 6ea3305c93
7 changed files with 23 additions and 8 deletions

View file

@ -1,7 +1,7 @@
---
- name: Restart NTP
service:
name: ntp
name: '{{ ntp_service_name }}'
state: restarted

View file

@ -1,4 +1,10 @@
---
- name: Check selected timesync daemon
fail:
fail_msg: "{{ timesync_daemon|default('No daemon') }} not supported"
when: timesync_daemon not in [ "ntp", "timesyncd" ]
- name: Include each network variables if there is no host variable
include_vars: "vars/timesync_{{ ansible_default_ipv4.network }}.yml"
when: ansible_default_ipv4 and timesync_servers is not defined
@ -10,11 +16,13 @@
when: timesync_servers is not defined
- include_tasks: timesync_timesyncd.yml
when: timesync_daemon == "timesyncd"
- name: Include OS dependent variables
include_vars: "{{ item }}"
with_first_found:
- "os_{{ (ansible_os_family|lower).split(' ')[0] }}.yml"
- "os_defaut.yml"
- include_tasks: timesync_ntp.yml
when: timesync_daemon not in ["timesyncd", ]
- include_tasks: "timesync_{{ timesync_daemon }}.yml"

View file

@ -12,7 +12,7 @@ filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# NTP server pool
{% for server in timesync_servers %}server {{ server }} iburst
{% for server in timesync_servers|default(["pool.ntp.org"]) %}server {{ server }} iburst
{% endfor %}

View file

@ -3,8 +3,8 @@
# See timesyncd.conf(5) for details.
[Time]
NTP={% for server in timesync_servers %}{{ server }} {% endfor %}
{% if timesync_servers_fallback|default([]) %}FallbackNTP={% for server in timesync_servers_fallback %}{{ server }} {% endfor %}
NTP={{ timesync_servers|default([])|join(' ') }}
{% if timesync_servers_fallback|default([]) %}FallbackNTP={{ timesync_servers_fallback|join(' ') }}
{% else %}#FallbackNTP=
{% endif %}

View file

@ -0,0 +1,3 @@
---
ntp_service_name: ntp

View file

@ -0,0 +1,3 @@
---
ntp_service_name: ntpd

View file

@ -0,0 +1 @@
os_debian.yml