forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some initial changes for using chrony instead of NTP
Signed-off-by: Saikrishna Arcot <[email protected]>
- Loading branch information
1 parent
06a90a8
commit 86e1558
Showing
14 changed files
with
141 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
sonic-cfggen -d -t /usr/share/sonic/templates/chrony.conf.j2 >/etc/chrony/chrony.conf | ||
sonic-cfggen -d -t /usr/share/sonic/templates/chrony.keys.j2 >/etc/chrony/chrony.keys | ||
chmod o-r /etc/chrony/chrony.keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
############################################################################### | ||
# This file was AUTOMATICALLY GENERATED. DO NOT MODIFY. | ||
# Controlled by ntp-config.service | ||
############################################################################### | ||
|
||
# Welcome to the chrony configuration file. See chrony.conf(5) for more | ||
# information about usable directives. | ||
|
||
# Include configuration files found in /etc/chrony/conf.d. | ||
confdir /etc/chrony/conf.d | ||
|
||
{# Getting NTP global configuration -#} | ||
{% set global = (NTP | d({})).get('global', {}) -%} | ||
|
||
{# Adding NTP servers. We need to know if we have some pools, to set proper config -#} | ||
{% set ns = namespace(is_pools=false) %} | ||
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' -%} | ||
{% set config = NTP_SERVER[server] -%} | ||
{# Server options -#} | ||
{% set soptions = '' -%} | ||
|
||
{# Define defaults if not defined -#} | ||
{% set association_type = config.association_type | d('server') -%} | ||
{% set resolve_as = config.resolve_as | d(server) -%} | ||
|
||
{# Authentication key -#} | ||
{% if global.authentication == 'enabled' -%} | ||
{% if config.key -%} | ||
{% set soptions = soptions ~ ' key ' ~ config.key -%} | ||
{% endif -%} | ||
{% endif -%} | ||
|
||
{# Aggressive polling -#} | ||
{% if config.iburst -%} | ||
{% set soptions = soptions ~ ' iburst' -%} | ||
{% endif -%} | ||
|
||
{# Protocol version -#} | ||
{% if config.version -%} | ||
{% set soptions = soptions ~ ' version ' ~ config.version -%} | ||
{% endif -%} | ||
|
||
{# Check if there are any pool configured. BTW it doesn't matter what was | ||
configured as "resolve_as" for pools. If they were configured with FQDN they | ||
must remain like that -#} | ||
{% if association_type == 'pool' -%} | ||
{% set resolve_as = server -%} | ||
{% endif -%} | ||
|
||
{{ association_type }} {{ resolve_as }}{{ soptions }} | ||
|
||
{% endfor -%} | ||
|
||
{# Access control options -#} | ||
{% set options = '' -%} | ||
|
||
{# Disable NTP server functionality. Should stay on when dhcp is enabled -#} | ||
{# {% if global.server_role == 'disabled' and global.dhcp == 'disabled' -%} | ||
{% set options = options ~ ' ignore' -%} | ||
{% endif -%} #} | ||
|
||
# Access control configuration | ||
# By default, exchange time with everybody, but don't allow configuration. | ||
# NTPsec doesn't establish peer associations, and so nopeer has no effect, and | ||
# has been removed from here | ||
restrict default kod nomodify noquery limited{{ options }} | ||
|
||
# Use time sources from DHCP. | ||
sourcedir /run/chrony-dhcp | ||
|
||
# Use NTP sources found in /etc/chrony/sources.d. | ||
sourcedir /etc/chrony/sources.d | ||
|
||
{% if global.authentication == 'enabled' %} | ||
# This directive specify the location of the file containing ID/key pairs for | ||
# NTP authentication. | ||
keyfile /etc/chrony/chrony.keys | ||
{% endif %} | ||
|
||
# This directive specify the file into which chronyd will store the rate | ||
# information. | ||
driftfile /var/lib/chrony/chrony.drift | ||
|
||
# Save NTS keys and cookies. | ||
ntsdumpdir /var/lib/chrony | ||
|
||
# Uncomment the following line to turn logging on. | ||
#log tracking measurements statistics | ||
|
||
# Log files location. | ||
logdir /var/log/chrony | ||
|
||
# Stop bad estimates upsetting machine clock. | ||
maxupdateskew 100.0 | ||
|
||
# This directive enables kernel synchronisation (every 11 minutes) of the | ||
# real-time clock. Note that it can’t be used along with the 'rtcfile' directive. | ||
rtcsync | ||
|
||
# Step the system clock instead of slewing it if the adjustment is larger than | ||
# one second, but only in the first three clock updates. | ||
makestep 1 3 | ||
|
||
# Get TAI-UTC offset and leap seconds from the system tz database. | ||
# This directive must be commented out when using time sources serving | ||
# leap-smeared time. | ||
leapsectz right/UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
############################################################################### | ||
# This file was AUTOMATICALLY GENERATED. DO NOT MODIFY. | ||
# Controlled by ntp-config.service | ||
############################################################################### | ||
|
||
{# We can connect only to the servers we trust. Determine those servers -#} | ||
{% set trusted_arr = [] -%} | ||
{% for server in NTP_SERVER if NTP_SERVER[server].trusted == 'yes' and | ||
NTP_SERVER[server].resolve_as -%} | ||
{% set _ = trusted_arr.append(NTP_SERVER[server].resolve_as) -%} | ||
{% endfor -%} | ||
|
||
{# Define authentication keys inventory -#} | ||
{% set trusted_str = ' ' ~ trusted_arr|join(',') -%} | ||
{% for keyid in NTP_KEY if NTP_KEY[keyid].type and NTP_KEY[keyid].value %} | ||
{% set keyval = NTP_KEY[keyid].value | b64decode %} | ||
{{ keyid }} {{ NTP_KEY[keyid].type | upper }} {{ keyval }}{{trusted_str}} | ||
{% endfor -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Unit] | ||
BindsTo=sonic.target | ||
After=sonic.target |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.