1
1
###############################################################################
2
- # Managed by Ansible
3
- # file: ansible/roles/acs/templates/ ntp.conf.j2
2
+ # This file was AUTOMATICALLY GENERATED. DO NOT MODIFY.
3
+ # Controlled by ntp-config.service
4
4
###############################################################################
5
5
6
- # /etc/ntpsec/ ntp.conf, configuration for ntpd; see ntp.conf(5) for help
6
+ # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
7
7
8
8
# To avoid ntpd from panic and exit if the drift between new time and
9
9
# current system time is large.
@@ -12,35 +12,82 @@ tinker panic 0
12
12
driftfile /var/lib/ntpsec/ntp.drift
13
13
leapfile /usr/share/zoneinfo/leap-seconds.list
14
14
15
- # To enable Network Time Security support as a server, obtain a certificate
16
- # (e.g. with Let's Encrypt), configure the paths below, and uncomment:
17
- # nts cert CERT_FILE
18
- # nts key KEY_FILE
19
- # nts enable
20
-
21
- # You must create /var/log/ntpsec (owned by ntpsec:ntpsec) to enable logging.
22
- #statsdir /var/log/ntpsec/
23
- #statistics loopstats peerstats clockstats
24
- #filegen loopstats file loopstats type day enable
25
- #filegen peerstats file peerstats type day enable
26
- #filegen clockstats file clockstats type day enable
27
-
28
- # Specify one or more NTP servers.
29
-
30
- # Public NTP servers supporting Network Time Security:
31
- # server time.cloudflare.com nts
32
- {% for ntp_server in NTP_SERVER %}
33
- server {{ ntp_server }} iburst
15
+ {# Getting NTP global configuration -#}
16
+ {% set global = (NTP | d ({})).get ('global' , {}) -%}
17
+
18
+ {# Adding NTP servers. We need to know if we have some pools, to set proper
19
+ config -#}
20
+ {% 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 -%}
24
+ {% set config = NTP_SERVER [server ] -%}
25
+ {# Server options -#}
26
+ {% set soptions = '' -%}
27
+ {# Server access control options -#}
28
+ {% set aoptions = '' -%}
29
+
30
+ {# Authentication key -#}
31
+ {% if global .authentication == 'enabled' -%}
32
+ {% if config .key -%}
33
+ {% set soptions = soptions ~ ' key ' ~ config .key -%}
34
+ {% endif -%}
35
+ {% endif -%}
36
+
37
+ {# Aggressive polling -#}
38
+ {% if config .iburst -%}
39
+ {% set soptions = soptions ~ ' iburst' -%}
40
+ {% endif -%}
41
+
42
+ {# Protocol version -#}
43
+ {% if config .version -%}
44
+ {% set soptions = soptions ~ ' version ' ~ config .version -%}
45
+ {% endif -%}
46
+
47
+ {# Check if there are any pool configured. BTW it doesn't matter what was
48
+ configured as "resolve_as" for pools. If they were configured with FQDN they
49
+ 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 -%}
54
+ {% else -%}
55
+ {% set aoptions = aoptions ~ ' nopeer' -%}
56
+ {% endif -%}
57
+
58
+ {{ config.association_type }} {{ config_as }}{{ soptions }}
59
+ {% if global .server_role == 'disabled' %}
60
+ restrict {{ config_as }} kod limited nomodify notrap noquery{{ aoptions }}
61
+ {% endif %}
62
+
63
+ {% endfor -%}
64
+
65
+ {% set trusted_keys_arr = [] -%}
66
+ {% for key in NTP_KEY -%}
67
+ {% set keydata = NTP_KEY [key ] -%}
68
+ {% if keydata .trusted == 'yes' -%}
69
+ {% set trusted_keys_arr = trusted_keys_arr .append (key ) -%}
70
+ {% endif -%}
34
71
{% endfor %}
35
72
36
- # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
37
- # pick a different set every time it starts up. Please consider joining the
38
- # pool: <https: //www.pool.ntp.org /join.html >
73
+ {% if global .authentication == 'enabled' %}
74
+ keys /etc/ntpsec/ntp.keys
75
+ {% if trusted_keys_arr != [] %}
76
+ trustedkey {{ trusted_keys_arr|join(' ') }}
77
+ {% endif %}
78
+ {% endif %}
39
79
40
- # listen on source interface if configured, else
41
- #only listen on MGMT_INTERFACE, LOOPBACK_INTERFACE ip when MGMT_INTERFACE is not defined, or eth0
42
- # if we don't have both of them (default is to listen on all ip addresses)
80
+ {# listen on source interface if configured, else only listen on MGMT_INTERFACE,
81
+ LOOPBACK_INTERFACE ip when MGMT_INTERFACE is not defined, or eth0 if we don't
82
+ have both of them (default is to listen on all ip addresses) -#}
43
83
interface ignore wildcard
84
+
85
+ {# Set interface to listen on:
86
+ * Set global variable for configured source interface name.
87
+ * Set global boolean to indicate if the ip of the configured source
88
+ interface is configured.
89
+ * If the source interface is configured but no ip on that
90
+ interface, then listen on another interface based on existing logic. -#}
44
91
{% - macro check_ip_on_interface (interface_name , table_name ) %}
45
92
{% - set ns = namespace (valid_intf = 'false' ) %}
46
93
{% - if table_name %}
@@ -55,8 +102,8 @@ interface ignore wildcard
55
102
56
103
{% set ns = namespace (source_intf = "" ) %}
57
104
{% - set ns = namespace (source_intf_ip = 'false' ) %}
58
- {% - if ( NTP ) and ( NTP [ ' global' ][ ' src_intf' ]) %}
59
- {% - set ns .source_intf = ( NTP [ ' global' ][ ' src_intf' ]) %}
105
+ {% - if global . src_intf %}
106
+ {% - set ns .source_intf = global . src_intf %}
60
107
{% - if ns .source_intf != "" %}
61
108
{% - if ns .source_intf == "eth0" %}
62
109
{% - set ns .source_intf_ip = 'true' %}
@@ -91,16 +138,19 @@ interface listen eth0
91
138
{% endif %}
92
139
interface listen 127.0.0.1
93
140
94
- # Access control configuration; see /usr/share/doc/ntpsec-doc/html/accopt.html
95
- # for details.
96
- #
97
- # Note that "restrict" applies to both servers and clients, so a configuration
98
- # that might be intended to block requests from certain clients could also end
99
- # up blocking replies from your own upstream servers.
141
+ {# Access control options -#}
142
+ {% set options = '' -%}
143
+
144
+ {# Disable NTP server functionality. Should stay on when dhcp is enabled -#}
145
+ {# {% if global.server_role == 'disabled' and global.dhcp == 'disabled' -%}
146
+ {% set options = options ~ ' ignore' -%}
147
+ {% endif -%} #}
100
148
149
+ # Access control configuration
101
150
# By default, exchange time with everybody, but don't allow configuration.
102
- # NTPsec doesn't establish peer associations, and so nopeer has no effect, and has been removed from here
103
- restrict default kod nomodify noquery limited
151
+ # NTPsec doesn't establish peer associations, and so nopeer has no effect, and
152
+ # has been removed from here
153
+ restrict default kod nomodify noquery limited{{ options }}
104
154
105
155
# Local users may interrogate the ntp server more closely.
106
156
restrict 127.0.0.1
0 commit comments