ansible chrony ntp

Core Idea

Chrony keeps system time accurate where classic NTP struggles: offline machines and unstable networks, with faster synchronization and clear advantages over the traditional daemon.

  • Key components and features of the suite.
  • Advantages over traditional NTP, and the systems it suits (offline or variable-connection hosts).
  • Typical use cases plus installation and configuration on Debian/Ubuntu and Red Hat/CentOS.

Chrony is an open-source software suite designed for maintaining accurate system time in Linux-based and UNIX-like operating systems. It provides an alternative to the Network Time Protocol (NTP) daemon and is particularly well-suited for systems that are:

  • Offline for extended periods.
  • Running on unstable or highly variable network connections.
  • Virtualized, where host clock drift is significant.

The official website for the project is chrony-project.org.

Key Components:

  1. Chronyd: A daemon that runs in the background and adjusts the system clock based on NTP servers or other time sources.
  2. Chronyc: A command-line interface that allows administrators to monitor and configure chronyd.

Features:

  • Fast synchronization: Quickly brings the system time into sync.
  • Handle offline systems: Can sync time effectively even after periods of disconnection.
  • Low resource usage: Suitable for embedded systems and low-power devices.
  • Support for multiple time sources: Includes NTP servers, hardware clocks, and manual inputs.
  • High accuracy: Uses advanced algorithms to adjust the clock.

Advantages over traditional NTP:

  • Better at handling intermittent network connectivity.
  • Works well with virtualized environments, where clock skew can occur frequently.
  • Can synchronize with reference clocks other than NTP, such as GPS.

Typical Use Cases:

  • Embedded systems.
  • Virtual machines.
  • Systems that frequently disconnect from the network.
  • Environments requiring high-precision timekeeping.

Installation and Configuration:

On most Linux distributions, chrony can be installed via the package manager. For example:

# On Debian/Ubuntu
sudo apt update
sudo apt install chrony
 
# On Red Hat/CentOS
sudo yum install chrony

The configuration file is typically located at /etc/chrony/chrony.conf, where you can define time servers, access restrictions, and other settings.