이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 28. Configuring time synchronization by using RHEL system roles


The Network Time Protocol (NTP) and Precision Time Protocol (PTP) are standards to synchronize the clock of computers over a network. By using the timesync RHEL system role, you can automate the configuration of time synchronization on RHEL.

An accurate time synchronization in networks is important because certain services rely on it. For example, Kerberos tolerates only a small time difference between the server and client to prevent replay attacks.

You can set the time service to configure in the timesync_ntp_provider variable of a playbook. If you do not set this variable, the role determines the time service based on the following factors:

  • On RHEL 8 and later: chronyd
  • On RHEL 6 and 7: chronyd (default) or, if already installed ntpd.

28.1. Configuring time synchronization over NTP by using the timesync RHEL system role

The Network Time Protocol (NTP) synchronizes the time of a host with an NTP server over a network. By using the timesync RHEL system role, you can automate the configuration of RHEL NTP clients in your network and keep the time synchronized.

Warning

The timesync RHEL system role replaces the configuration of the specified given or detected provider service on the managed host. Consequently, all settings are lost if they are not specified in the playbook.

Prerequisites

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Managing time synchronization
      hosts: managed-node-01.example.com
      tasks:
        - name: Configuring NTP with an internal server (preferred) and a public server pool as fallback
          ansible.builtin.include_role:
            name: redhat.rhel_system_roles.timesync
          vars:
            timesync_ntp_servers:
            - hostname: time.example.com
              trusted: yes
              prefer: yes
              iburst: yes
            - hostname: 0.rhel.pool.ntp.org
              pool: yes
              iburst: yes

    The settings specified in the example playbook include the following:

    pool: <yes|no>
    Flags a source as an NTP pool rather than an individual host. In this case, the service expects that the name resolves to multiple IP addresses which can change over time.
    iburst: yes
    Enables fast initial synchronization.

    For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.timesync/README.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml

Verification

  • Display the details about the time sources:

    • If the managed node runs the chronyd service, enter:

      # ansible managed-node-01.example.com -m command -a 'chronyc sources'
      MS Name/IP address         Stratum Poll Reach LastRx Last sample
      ===============================================================================
      ^* time.example.com              1  10   377   210   +159us[  +55us] +/-   12ms
      ^? ntp.example.org               2   9   377   409  +1120us[+1021us] +/-   42ms
      ^? time.us.example.net           2   9   377   992   -329us[ -386us] +/-   15ms
      ...
    • If the managed node runs the ntpd service, enter:

      # ansible managed-node-01.example.com -m command -a 'ntpq -p'
           remote           refid      st t when poll reach   delay   offset  jitter
      ==============================================================================
      *time.example.com .PTB.           1 u    2   64   77   23.585  967.902   0.684
      - ntp.example.or 192.0.2.17       2 u    -   64   77   27.090  966.755   0.468
      +time.us.example 198.51.100.19    2 u   65   64   37   18.497  968.463   1.588
      ...

By using the Network Time Security (NTS) mechanism, clients establish a TLS-encrypted connection to the server and authenticate Network Time Protocol (NTP) packets. By using the timesync RHEL system role, you can automate the configuration of RHEL NTP clients with NTS.

Note that you cannot mix NTS servers with non-NTS servers. In mixed configurations, NTS servers are trusted and clients do not fall back to unauthenticated NTP sources because they can be exploited in man-in-the-middle (MITM) attacks. For further details, see the authselectmode parameter description in the chrony.conf(5) man page on your system.

Warning

The timesync RHEL system role replaces the configuration of the specified given or detected provider service on the managed host. Consequently, all settings are lost if they are not specified in the playbook.

Prerequisites

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Managing time synchronization
      hosts: managed-node-01.example.com
      tasks:
        - name: Configuring NTP with NTS-enabled servers
          ansible.builtin.include_role:
            name: redhat.rhel_system_roles.timesync
          vars:
            timesync_ntp_servers:
            - hostname: ptbtime1.ptb.de
              nts: yes
              iburst: yes

    The settings specified in the example playbook include the following:

    iburst: yes
    Enables fast initial synchronization.

    For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.timesync/README.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml

Verification

  • If the managed node runs the chronyd service:

    1. Display the details about the time sources:

      # ansible managed-node-01.example.com -m command -a 'chronyc sources'
      MS Name/IP address         Stratum Poll Reach LastRx Last sample
      ===============================================================================
      ^* ptbtime1.ptb.de               1   6    17    55    -13us[  -54us] +/-   12ms
      ^- ptbtime2.ptb.de               1   6    17    56   -257us[ -297us] +/-   12ms
    2. For sources with NTS enabled, display information that is specific to authentication of NTP sources:

      # ansible managed-node-01.example.com -m command -a 'chronyc -N authdata'
      Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
      =========================================================================
      ptbtime1.ptb.de              NTS     1   15  256  229    0    0    8  100
      ptbtime2.ptb.de              NTS     1   15  256  230    0    0    8  100

      Verify that the reported number of cookies in the Cook column is larger than 0.

  • If the managed node runs the ntpd service, enter:

    # ansible managed-node-01.example.com -m command -a 'ntpq -p'
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *ptbtime1.ptb.de .PTB.            1 8    2   64   77   23.585  967.902   0.684
    -ptbtime2.ptb.de .PTB.            1 8   30   64   78   24.653  993.937   0.765
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동