ansible-playbooks/roles/ntp-chrony
2025-12-13 23:49:39 +01:00
..
defaults chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00
handlers chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00
tasks chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00
templates chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00
vars chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00
README.md chore: replace ntpd by chrony 2025-12-13 23:49:39 +01:00

Chrony NTP Client/Server

Modern NTP implementation for time synchronization. Chrony is designed for systems with intermittent network connectivity and is the default NTP client on modern Linux distributions.

Features

  • Fast initial time synchronization
  • Client mode: sync time from NTP pools/servers
  • Server mode: serve time to local network clients
  • Automatic conflict resolution with systemd-timesyncd and ntpd
  • Firewall integration for server mode

Usage

Client-only mode (default)

Sync time from public NTP pools, don't serve time to others:

# host_vars/example.yml
ntp_timezone: "Europe/Paris"
ntp_pools:
  - "0.fr.pool.ntp.org"
  - "1.fr.pool.ntp.org"
  - "2.fr.pool.ntp.org"
  - "3.fr.pool.ntp.org"

Server mode

Serve time to local network:

# host_vars/ntp-server.yml
ntp_timezone: "UTC"
ntp_server_enabled: true
ntp_allowed_networks:
  - 192.168.1.0/24  # Configures both chrony and firewall
  - 192.168.27.0/27

Client syncing from local server

# host_vars/client.yml
ntp_pools: []  # Don't use public pools
ntp_servers:
  - server: ntp.local.lan
    options: iburst prefer
  - server: 192.168.1.1
    options: iburst

Logging

Default: journald - Logs to systemd journal (recommended)

# View chrony logs
journalctl -u chronyd -f

Optional: File-based logging with automatic rotation

ntp_log_backend: file
ntp_log_measurements: true
ntp_log_statistics: true
ntp_log_tracking: true

Variables

See defaults/main.yml for all configuration options.

Verification

# Check chrony status
chronyc tracking

# Show current time sources
chronyc sources

# Show detailed source stats
chronyc sourcestats

Resources