Skip to content

Commit 2e1892b

Browse files
authored
🐞 NTP: Fix config template to init default parameters (#18736) (#18981)
fixes #17906 To fix NTP config generation from the minigraph and save backward compatability Align `ntp.conf.j2` template to generate config out of empty `NTP_SERVER` DB configuration Out of that NTP_SERVER configuration: ```json { "10.210.25.32": {}, "10.75.202.2": {} } ``` The next config in `ntp.conf` file should be produced: ``` server 10.210.25.32 restrict 10.210.25.32 kod limited nomodify notrap noquery nopeer server 10.75.202.2 restrict 10.75.202.2 kod limited nomodify notrap noquery nopeer ``` Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent 10831ac commit 2e1892b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

files/image_config/ntp/ntp.conf.j2

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ filegen clockstats file clockstats type day enable
2020
{# Adding NTP servers. We need to know if we have some pools, to set proper
2121
config -#}
2222
{% set ns = namespace(is_pools=false) %}
23-
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' and
24-
NTP_SERVER[server].resolve_as and
25-
NTP_SERVER[server].association_type -%}
23+
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' -%}
2624
{% set config = NTP_SERVER[server] -%}
2725
{# Server options -#}
2826
{% set soptions = '' -%}
2927
{# Server access control options -#}
3028
{% set aoptions = '' -%}
3129

30+
{# Define defaults if not defined -#}
31+
{% set association_type = config.association_type | d('server') -%}
32+
{% set resolve_as = config.resolve_as | d(server) -%}
33+
3234
{# Authentication key -#}
3335
{% if global.authentication == 'enabled' -%}
3436
{% if config.key -%}
@@ -49,17 +51,16 @@ config -#}
4951
{# Check if there are any pool configured. BTW it doesn't matter what was
5052
configured as "resolve_as" for pools. If they were configured with FQDN they
5153
must remain like that -#}
52-
{% set config_as = config.resolve_as -%}
53-
{% if config.association_type == 'pool' -%}
54+
{% if association_type == 'pool' -%}
5455
{% set ns.is_pools = true -%}
55-
{% set config_as = server -%}
56+
{% set resolve_as = server -%}
5657
{% else -%}
5758
{% set aoptions = aoptions ~ ' nopeer' -%}
5859
{% endif -%}
5960

60-
{{ config.association_type }} {{ config_as }}{{ soptions }}
61+
{{ association_type }} {{ resolve_as }}{{ soptions }}
6162
{% if global.server_role == 'disabled' %}
62-
restrict {{ config_as }} kod limited nomodify notrap noquery{{ aoptions }}
63+
restrict {{ resolve_as }} kod limited nomodify notrap noquery{{ aoptions }}
6364
{% endif %}
6465

6566
{% endfor -%}

0 commit comments

Comments
 (0)