Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Last active February 4, 2026 20:22
Show Gist options
  • Select an option

  • Save mschmitt/0895da5e328775858b21bf4e5cc8d56c to your computer and use it in GitHub Desktop.

Select an option

Save mschmitt/0895da5e328775858b21bf4e5cc8d56c to your computer and use it in GitHub Desktop.
Replace systemd-timesyncd with standard ntpd
# sudo bash -c 'ansible-playbook <(curl -s https://gist.githubusercontent.com/mschmitt/0895da5e328775858b21bf4e5cc8d56c/raw/play-ntp.yml)'
---
- hosts: localhost
gather_facts: true
connection: local
tasks:
- name: Disable systemd-timesyncd
systemd_service:
name: systemd-timesyncd
state: stopped
enabled: false
- name: Install ntp (Arch)
package:
name: ntp
state: present
when: ansible_facts['os_family'] == 'Archlinux'
- name: Install ntpsec and ntpdate (Debian)
package:
name:
- ntpsec
- ntpsec-ntpdate
state: present
when: ansible_facts['os_family'] == 'Debian'
- name: Ensure ntpd is stopped
systemd_service:
name: ntpd
state: stopped
- name: Acquire time
command: ntpdate pool.ntp.org
- name: Start and enable ntpdate (Arch)
systemd_service:
name: ntpd
state: started
enabled: true
when: ansible_facts['os_family'] == 'Archlinux'
- name: Start and enable ntpd
systemd_service:
name: ntpd
state: started
enabled: true
# vim: filetype=yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment