linux-system-roles.timesync

Time Sync

Lint Test Markdown Lint Shell Check Terraform Test Terraform CI Test Woke

This role sets up and configures NTP (Network Time Protocol) and/or PTP (Precision Time Protocol) to synchronize your system clock with NTP servers and/or PTP grandmasters. The supported implementations are chrony, ntp (standard), and linuxptp.

Warning

This role will replace any existing configuration of the chosen service on the managed server. Previous settings will be erased, even if they are not part of the role settings (there is no attempt to keep or combine old settings). The only setting that will be retained is the choice of the provider if timesync_ntp_provider is not specified (see details on this variable below).

Requirements

See below.

Collection Requirements

To manage systems with rpm-ostree, this role requires modules from external collections. Install them with the following command:

ansible-galaxy collection install -vv -r meta/collection-requirements.yml

Role Variables

You can set the following variables for this role:

# List of NTP servers
timesync_ntp_servers:
  - hostname: foo.example.com   # Server's hostname or address
    minpoll: 4                  # Minimum poll interval (default 6)
    maxpoll: 8                  # Maximum poll interval (default 10)
    iburst: true                # Enable fast initial synchronization (default false)
    pool: false                 # Treat resolved hostname addresses as separate NTP servers (default false)
    nts: false                  # Enable Network Time Security (NTS) (default false, chrony >= 4.0 required)
    prefer: false               # Mark this source to be preferred for synchronization (default false)
    trust: false                # Mark this source as trusted (default false)
    xleave: false               # Enable interleaved mode (default false)
    filter: 1                   # Number of NTP measurements per clock update (default 1)

# List of PTP domains
timesync_ptp_domains:
  - number: 0                   # PTP domain number
    interfaces: [eth0]          # Interfaces in the domain
    delay: 0.000010             # Assumed maximum network delay to the grandmaster in seconds (default 100 microseconds)
    transport: UDPv4            # Transport method: UDPv4, UDPv6, L2 (default UDPv4)
    udp_ttl: 1                  # TTL for UDPv4 and UDPv6 (default 1)
    hybrid_e2e: false           # Enable unicast end-to-end delay requests (default false)

# Enable use of DHCP provided NTP servers (default false)
timesync_dhcp_ntp_servers: false

# Minimum clock offset that can be corrected by stepping (defaults vary by implementation)
timesync_step_threshold: 1.0

# Maximum distance acceptable for NTP server measurements
timesync_max_distance: 0

# Minimum number of time sources required for synchronization (default 1)
timesync_min_sources: 1

# Interfaces for hardware timestamping with NTP (default empty list). Use '*' for all supported interfaces.
timesync_ntp_hwts_interfaces: ["*"]

# Package to be installed for NTP. Options: "chrony", "ntp". If not set, the active service will be configured.
timesync_ntp_provider: chrony

# Custom settings for chrony not included by default. Example: logging measurements, statistics, and tracking:
timesync_chrony_custom_settings:
  - "logdir /var/log/chrony"
  - "log measurements statistics tracking"

# If a transactional update needs a reboot, this variable allows for it if set to true.
timesync_transactional_update_reboot_ok: true

Example Playbooks

Install and configure NTP with three servers:

- name: Manage timesync with 3 servers
  hosts: targets
  vars:
    timesync_ntp_servers:
      - hostname: foo.example.com
        iburst: true
      - hostname: bar.example.com
        iburst: true
      - hostname: baz.example.com
        iburst: true
  roles:
    - linux-system-roles.timesync

Install and configure linuxptp for PTP domain 0 on interface eth0:

- name: Manage timesync in PTP domain 0, interface eth0
  hosts: targets
  vars:
    timesync_ptp_domains:
      - number: 0
        interfaces: [eth0]
  roles:
    - linux-system-roles.timesync

Install and configure both chrony and linuxptp for accurate synchronization:

- name: Manage multiple NTP servers and PTP domains
  hosts: targets
  vars:
    timesync_ntp_servers:
      - hostname: foo.example.com
        maxpoll: 6
      - hostname: bar.example.com
        maxpoll: 6
      - hostname: baz.example.com
        maxpoll: 6
    timesync_ptp_domains:
      - number: 0
        interfaces: [eth0, eth1]
        transport: L2
        delay: 0.000010
      - number: 1
        interfaces: [eth2]
        transport: UDPv4
        delay: 0.000010
  roles:
    - linux-system-roles.timesync

Install and configure chrony with custom settings for logging:

- name: Manage with custom advanced settings
  hosts: targets
  vars:
    timesync_ntp_servers:
      - hostname: foo.example.com
      - hostname: bar.example.com
      - hostname: baz.example.com
    timesync_chrony_custom_settings:
      - "logdir /var/log/chrony"
      - "log measurements statistics tracking"
  roles:
    - linux-system-roles.timesync

rpm-ostree

See README-ostree.md

Installa
ansible-galaxy install linux-system-roles.timesync
Licenza
mit
Download
741.9k
Proprietario