ans2dev.general.chrony_info module – Collect chrony information.

Note

This module is part of the ans2dev.general collection (version 0.2.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ans2dev.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: ans2dev.general.chrony_info.

New in ans2dev.general 0.2.0

Synopsis

  • Retrieves chrony information using chronyd and chronyc commands.

  • Collects configuration, sources, sourcestat and ntpdata info based on mode option.

  • Pay attention to the requirements section before using this module.

Requirements

The below requirements are needed on the host that executes this module.

  • chronyd command with -p option.

  • chronyc command with -n sources, sourcestats and ntpdata options.

  • chronyd.service must be running to use sources, sourcestats and ntpdata in mode option.

Parameters

Parameter

Comments

IP

string

This option is only applicable when mode is ntpdata.

It allows you to limit the data collection to a single NTP server by specifying its IP address.

When used with ntpdata in mode module collects only the data for the provided NTP server IP.

mode

string / required

This option specifies which type of chrony data the module should collect.

conf Returns the chronyd configuration, as obtained from the chronyd -p command.

sources Returns a flat list of dict representing the NTP sources table, as collected from the chronyc -n sources command.

sourcestats Returns a flat list of dict representing the NTP source statistics, as gathered via the chronyc -n sourcestats command.

ntpdata Returns detailed NTP testing data from chronyc ntpdata command for the configured servers.

Choices:

  • "conf"

  • "sources"

  • "sourcestats"

  • "ntpdata"

Notes

Note

  • Module requires register function in order to access to the collected info.

  • Module commands require chronyd.service in running state.

Examples

---
# Collect chronyd configuration
- name: Get chrony configuration info
  ans2dev.general.chrony_info:
    mode: conf
  register: result

# Collect sources data
- name: Get chrony sources table
  ans2dev.general.chrony_info:
    mode: sources
  register: result

# Collect sourcestats data
- name: Get chrony sourcestats table
  ans2dev.general.chrony_info:
    mode: sourcestats
  register: result

# Collect all ntpdata information from all configured servers
- name: Get chrony ntpdata info for all servers
  ans2dev.general.chrony_info:
    mode: ntpdata
  register: result

# Collect ntpdata only for a specific server
- name: Get chrony ntpdata info for a specific server
  ans2dev.general.chrony_info:
    mode: ntpdata
    IP: "100.110.92.1"
  register: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

conf

dictionary

Dictionary of chronyd configuration from chronyd -p command.

Additional fields will be returned depending on configuration file.

Returned: when mode is conf.

driftfile

string

This file stores the measured clock drift of the system.

chrony uses the drift value to make continuous adjustments to the local clock.

Returned: if conf.driftfile is in the configuration.

Sample: "/var/lib/chrony/drif"

keyfile

string

This file contains authentication keys.

It helps secure NTP exchanges.

Returned: if conf.keyfile is in the configuration.

Sample: "/etc/chrony.keys"

leapsectz

string

This setting specifies the time zone context used when applying leap second corrections.

Returned: if conf.leapsectz is in the configuration.

Sample: "right/UTC"

logdir

string

This directory is where chrony writes its log files.

Returned: if conf.logdir is in the configuration.

Sample: "/var/log/chrony"

makestep

string

The makestep directive controls when chrony will step the system clock rather than slowly slewing it.

Returned: if conf.makestep is in the configuration.

Sample: "1.0 3"

ntsdumpdir

string

This directory is used by chrony to store a dump of NTP data.

Returned: if conf.ntsdumpdir is in the configuration.

Sample: "/var/lib/chrony"

rtcsync

boolean

When set to true, this option instructs chrony to synchronize the Real Time Clock RTC with the system clock.

Returned: if conf.rtcsync is in the configuration.

Sample: true

server

list / elements=string

This is a list of NTP servers chrony uses to obtain the correct time.

The IP addresses are provided along with an additional option iburst.

Depending on configuration it return hostname and not ip server.

Returned: if conf.server is in the configuration.

Sample: ["100.110.92.1 iburst", "91.149.253.184 iburst"]

sourcedir

string

This directory contains additional configuration files or sources provided dynamically.

Returned: if conf.sourcedir is in the configuration.

Sample: "/run/chrony-dhcp"

ntpdata

dictionary

Dictionary of chronyd from chronyc ntpdata command for every configured server.

It is a complex dictionary that contains a dictionary for each configured IP.

If IP is used it return only ntpdata info for the selected IP Address.

Additional fields will be returned depending on chrony or OS Distribution.

Returned: when mode is ntpdata.

Authenticated

string

Indicates whether the NTP data received from the server is authenticated.

Returned: always

Sample: "False"

Interleaved

string

Shows whether the server is using interleaved from for packet exchange.

Returned: always

Sample: "False"

Jitter asymmetry

string

Represents the asymmetry in network jitter between transmit and receive paths.

Returned: always

Sample: "0.0"

Leap status

string

Reports the leap second status.

Returned: always

Sample: "Normal"

Local address

string

Provides the local network address and additional numeric code that the system is using for communicating with the remote NTP server.

Returned: always

Sample: "[UNSPEC] (00000000)"

Mode

string

Indicates the NTP mode in which the server is operating.

Returned: always

Sample: "Invalid"

NTP tests

string

Displays the results of various NTP internal tests.

The string consists of multiple sets of digits, with each group representing a particular outcome test.

Returned: always

Sample: "000 000 0000"

Offset

string

Reflects the measured time difference between the local system clock and the remote NTP server clock.

Returned: always

Sample: "+0.000000000 seconds"

Peer delay

string

Measures the delay between the local system and the peer.

Returned: always

Sample: "0.000000000 seconds"

Peer dispersion

string

Represents the dispersion in delay measurements to the remote server.

Returned: always

Sample: "0.000000000 seconds"

Poll interval

string

Shows the polling interval used by chrony.

Returned: always

Sample: "0 (1 seconds)"

Precision

string

Indicates the precision of the system clock as measured by chrony.

Returned: always

Sample: "0 (1.000000000 seconds)"

Reference ID

string

Identifies the reference clock or time source that the server uses as its basis.

Returned: always

Sample: "00000000 ()"

Reference time

string

Shows the time at which the server last synchronized with its reference clock.

Returned: always

Sample: "Thu Jan 01 00:00:00 1970"

Remote address

string

Displays the remote NTP server IP address along with an accompanying numeric code.

Returned: always

Sample: "100.110.92.1 (646E5C01)"

Remote port

string

Indicates the network port number used by the remote NTP server for communication.

Returned: always

Sample: "123"

Response time

string

Captures the round-trip time from when a request was sent to the remote server and when the response was received.

Returned: always

Sample: "0.000000000 seconds"

Root delay

string

Represents the total round-trip delay to the primary reference clock.

Returned: always

Sample: "0.000000 seconds"

Root dispersion

string

The dispersion associated with the root delay.

Returned: always

Sample: "0.000000 seconds"

RX timestamping

string

Specifies the method used for timestamping incoming received packets.

Returned: always

Sample: "Invalid"

Stratum

string

Denotes the stratum level of the server.

Stratum 0 is reserved for high-precision timekeeping devices.

Returned: always

Sample: "0"

Total good RX

string

The number of received packets that passed internal validation checks.

Returned: always

Sample: "0"

Total HW RX

string

Reflects the total count of received packets that were processed using hardware timestamping.

Returned: always

Sample: "0"

Total HW TX

string

Indicates the total count of transmitted packets that were processed using hardware timestamping.

Returned: always

Sample: "0"

Total kernel RX

string

Represents the number of packets received at the kernel level.

Returned: always

Sample: "0"

Total kernel TX

string

Represents the number of packets transmitted at the kernel level.

Returned: always

Sample: "9"

Total RX

string

The total number of packets received.

Returned: always

Sample: "0"

Total TX

string

The total number of packets transmitted to the server.

Returned: always

Sample: "9"

Total valid RX

string

The number of received packets that have been validated and considered correct by the NTP protocol criteria.

Returned: always

Sample: "0"

TX timestamping

string

Indicates the method used for timestamping outgoing transmitted packets.

Returned: always

Sample: "Invalid"

Version

string

Denotes the NTP protocol version used in the communication.

Returned: always

Sample: "0"

sources

list / elements=dictionary

Dictionary of chronyd from chronyc -n sources command.

Additional fields will be returned depending on chrony or OS Distribution.

Returned: when mode is sources.

Last sample

string

This column reports the most recent time measurement information received from the source.

Returned: always

Sample: "+0ns[ +0ns] +/- 0ns"

LastRx

string

This field indicates how long ago the last valid packet was received from the source.

Returned: always

Sample: "-"

MS

string

This field contains a status indicator for the source.

Returned: always

Sample: "^?"

Name/IP address

string

This field contains the hostname or IP address of the NTP source.

Returned: always

Sample: "100.110.92.1"

Poll

string

This is the polling interval, expressed typically as a power-of-two exponent in seconds.

Returned: always

Sample: "8"

Reach

string

This represents the reachability register for the source.

It is an 8-bit shift register that records the success or failure of recent attempts to contact the time server.

Returned: always

Sample: "0"

Stratum

string

This field represents the stratum level of the NTP server.

Returned: always

Sample: "0"

sourcestat

list / elements=dictionary

Dictionary of chronyd from chronyc -n sourcestats command.

Additional fields will be returned depending on chrony or OS Distribution.

Returned: when mode is sourcestats.

Freq Skew

string

This value represents the variability or statistical dispersion of the measured frequency offsets.

Returned: always

Sample: "2000.0"

Frequency

string

Reflects the average frequency offset or error of the local clock relative to the reference provided by the source.

It is expressed in a way that indicates how far off and in which direction the clock might be running.

Returned: always

Sample: "0.0"

Name/IP Address

string

The hostname or IP address of the NTP source from which measurements are taken.

Returned: always

Sample: "100.110.92.1"

NP

string

Often represents the number of measurement samples or packets that have been successfully collected and used for statistical analysis.

Returned: always

Sample: "0"

NR

string

Indicates the number of rejected measurements.

Returned: always

Sample: "0"

Offset

string

The average offset is the measured difference in time between the local system clock and the remote NTP source.

Returned: always

Sample: "+0ns"

Span

string

Represents the time span in seconds between the oldest and newest measurement sample used to compute the statistics.

Returned: always

Sample: "0"

Std Dev

string

This is the standard deviation of the offset measurements.

The standard deviation gives a sense of the spread or dispersion of the offset values.

Returned: always

Sample: "4000ms"

Authors

  • Marco Noce (@NomakCooper)