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

Added ntp sync handling for Debian and OpenBSD.

parent 64efa9bf
No related branches found
No related tags found
No related merge requests found
......@@ -23,3 +23,14 @@
service:
name: collectd
state: restarted
- name: Restart ntpd
service:
name: '{{ "ntpd" if ansible_os_family == "OpenBSD" else omit }}'
name: '{{ "ntp" if ansible_os_family == "Debian" else omit }}'
state: restarted
- name: Restart systemd-timesyncd
service:
name: systemd-timesyncd
state: restarted
......@@ -3,3 +3,9 @@
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- include: ntp_OpenBSD.yml
when: ansible_os_family == 'OpenBSD' or not ansible_init == 'systemd'
- include: systemd-timesyncd.yml
when: ansible_os_family == 'Debian' and ansible_init == 'systemd'
---
- assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: apt install ntpd
when: ansible_pkg_mgr == 'apt'
apt:
name: ntp
state: present
update_cache: yes
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
owner: root
group: wheel
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 }}'
enabled: yes
state: started
---
- name: Configure systemd-timesyncd
lineinfile:
dest: /etc/systemd/timesyncd.conf
line: 'NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org'
regexp: '^NTP='
state: present
notify:
- 'Restart systemd-timesyncd'
- name: Enable systemd-timesyncd
service:
name: systemd-timesyncd
enabled: yes
state: started
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment