Skip to content
Snippets Groups Projects
Commit ec25c39d authored by nimrod's avatar nimrod
Browse files

Better ntp sync handling.

parent 0e33c704
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,7 @@
- name: Restart ntpd
service:
name: '{{ "ntpd" if ansible_os_family == "OpenBSD" else omit }}'
name: '{{ "ntp" if ansible_os_family == "Debian" else omit }}'
name: '{{ ntpd_service[ansible_os_family] }}'
state: restarted
- name: Restart systemd-timesyncd
......
......@@ -12,23 +12,17 @@
cache_valid_time: 3600
- name: Configure ntpd
lineinfile:
line: '{{ "servers pool.ntp.org" if ansible_os_family == "OpenBSD" else omit }}'
line: '{{ "server debian.pool.ntp.org" if ansible_os_family == "OpenBSD" else omit }}'
regexp: '{{ "^servers " if ansible_os_family == "OpenBSD" else omit }}'
regexp: '{{ "^server " if ansible_os_family == "Debian" else omit }}'
dest: '{{ "/etc/ntpd.conf" if ansible_os_family == "OpenBSD" else omit }}'
dest: '{{ "/etc/ntp.conf" if ansible_os_family == "Debian" else omit }}'
create: yes
template:
src: ntpd.conf.j2
dest: '{{ ntpd_conf[ansible_os_family] }}'
owner: root
group: wheel
group: '{{ root_group[ansible_os_family] }}'
mode: '0644'
notify:
- Restart ntpd
- name: Enable ntpd
service:
name: '{{ "ntpd" if ansible_os_family == "OpenBSD" else omit }}'
name: '{{ "ntp" if ansible_os_family == "Debian" else omit }}'
name: '{{ ntpd_service[ansible_os_family] }}'
enabled: yes
state: started
{% for i in range(4) %}
server {{ i }}.{{ ntp_pool[ansible_os_family] }}
{% endfor %}
......@@ -47,3 +47,12 @@ root_group:
cert_dir:
OpenBSD: /etc/ssl/certs
Debian: /usr/local/share/ca-certificates
ntpd_conf:
OpenBSD: /etc/ntpd.conf
Debian: /etc/ntp.conf
ntp_pool:
OpenBSD: pool.ntp.org
Debian: debian.pool.ntp.org
ntpd_service:
OpenBSD: ntpd
Debian: ntp
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment