Skip to content

Commit ad03fae

Browse files
committed
🐞 NTP: Fix config template to init default parameters
Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent f60ef62 commit ad03fae

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

files/image_config/ntp/ntp.conf.j2

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ leapfile /usr/share/zoneinfo/leap-seconds.list
1818
{# Adding NTP servers. We need to know if we have some pools, to set proper
1919
config -#}
2020
{% set ns = namespace(is_pools=false) %}
21-
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' and
22-
NTP_SERVER[server].resolve_as and
23-
NTP_SERVER[server].association_type -%}
21+
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' -%}
2422
{% set config = NTP_SERVER[server] -%}
2523
{# Server options -#}
2624
{% set soptions = '' -%}
2725
{# Server access control options -#}
2826
{% set aoptions = '' -%}
2927

28+
{# Define defaults if not defined -#}
29+
{% set association_type = config.association_type | d('server') -%}
30+
{% set resolve_as = config.resolve_as | d(server) -%}
31+
3032
{# Authentication key -#}
3133
{% if global.authentication == 'enabled' -%}
3234
{% if config.key -%}
@@ -47,17 +49,15 @@ config -#}
4749
{# Check if there are any pool configured. BTW it doesn't matter what was
4850
configured as "resolve_as" for pools. If they were configured with FQDN they
4951
must remain like that -#}
50-
{% set config_as = config.resolve_as -%}
51-
{% if config.association_type == 'pool' -%}
52-
{% set ns.is_pools = true -%}
53-
{% set config_as = server -%}
52+
{% if association_type == 'pool' -%}
53+
{% set resolve_as = server -%}
5454
{% else -%}
5555
{% set aoptions = aoptions ~ ' nopeer' -%}
5656
{% endif -%}
5757

58-
{{ config.association_type }} {{ config_as }}{{ soptions }}
58+
{{ association_type }} {{ resolve_as }}{{ soptions }}
5959
{% if global.server_role == 'disabled' %}
60-
restrict {{ config_as }} kod limited nomodify notrap noquery{{ aoptions }}
60+
restrict {{ resolve_as }} kod limited nomodify notrap noquery{{ aoptions }}
6161
{% endif %}
6262

6363
{% endfor -%}

0 commit comments

Comments
 (0)