Merge ~paulgear/ntp-charm/+git/ntp-charm:chrony-support into ntp-charm:master
- Git
- lp:~paulgear/ntp-charm/+git/ntp-charm
- chrony-support
- Merge into master
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Paul Gear | ||||
Approved revision: | 9e7a3c32a64a7697834bfaf7fc07871fe7dc9a06 | ||||
Merged at revision: | ff753b4081d20cbf0ddc2fabf3a6b933a3006d23 | ||||
Proposed branch: | ~paulgear/ntp-charm/+git/ntp-charm:chrony-support | ||||
Merge into: | ntp-charm:master | ||||
Diff against target: |
488 lines (+288/-58) 7 files modified
config.yaml (+16/-14) hooks/ntp_hooks.py (+38/-33) hooks/ntp_implementation.py (+132/-0) templates/chrony.conf (+58/-0) templates/chrony.default (+13/-0) templates/ntp.conf (+29/-11) templates/ntp.default (+2/-0) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop (community) | Approve | ||
Review via email: mp+340780@code.launchpad.net |
Commit message
Add basic chrony support to ntp charm in preparation for bionic release. The Nagios check does not currently work with chrony.
Description of the change
First cut at adding chrony support to ntp charm in preparation for bionic release.
Seth Arnold (seth-arnold) wrote : | # |
Stuart Bishop (stub) wrote : | # |
Looks good.
I do strongly believe that the ntp_implementation config option should be dropped, as its only use case is to create broken or unsupported deployments. The function in ntp_implementat
Paul Gear (paulgear) wrote : | # |
That all makes good sense to me; will push a new rev shortly.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
This merge proposal is being monitored by mergebot. Change the status to Approved to merge.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Change successfully merged at revision ff753b4081d20cb
Preview Diff
1 | diff --git a/config.yaml b/config.yaml | |||
2 | index 1bbc1ed..993673d 100644 | |||
3 | --- a/config.yaml | |||
4 | +++ b/config.yaml | |||
5 | @@ -3,13 +3,13 @@ options: | |||
6 | 3 | default: "" | 3 | default: "" |
7 | 4 | type: string | 4 | type: string |
8 | 5 | description: > | 5 | description: > |
10 | 6 | Space-separated list of NTP servers to use as sources for time. | 6 | Space-separated list of NTP servers to use as time sources. |
11 | 7 | peers: | 7 | peers: |
12 | 8 | default: "" | 8 | default: "" |
13 | 9 | type: string | 9 | type: string |
14 | 10 | description: > | 10 | description: > |
17 | 11 | Space-separated list of NTP servers to use as peers for time. | 11 | Space-separated list of NTP servers to use as peers. Under ntpd, |
18 | 12 | Peers are allowed to query the local NTP server via ntpq. | 12 | peers are allowed to query the local NTP server via ntpq. |
19 | 13 | pools: | 13 | pools: |
20 | 14 | default: > | 14 | default: > |
21 | 15 | 0.ubuntu.pool.ntp.org | 15 | 0.ubuntu.pool.ntp.org |
22 | @@ -19,25 +19,27 @@ options: | |||
23 | 19 | ntp.ubuntu.com | 19 | ntp.ubuntu.com |
24 | 20 | type: string | 20 | type: string |
25 | 21 | description: > | 21 | description: > |
29 | 22 | Space-separated list of NTP servers to use as pool sources for | 22 | Space-separated list of NTP servers to use as pool sources. These |
30 | 23 | time. Pool sources are recommended over normal sources for their | 23 | are recommended over normal sources for their self-healing |
31 | 24 | self-healing capabilities. Leave empty to disable pool sources. | 24 | capabilities. Leave empty to disable pool sources. |
32 | 25 | orphan_stratum: | 25 | orphan_stratum: |
34 | 26 | default: 6 | 26 | default: 0 |
35 | 27 | type: int | 27 | type: int |
36 | 28 | description: > | 28 | description: > |
43 | 29 | The NTP stratum at which ntp most lose connectivity to before it | 29 | The stratum at which NTP must lose connectivity to before it considers |
44 | 30 | considers itself orphaned, and starts communicating with local peers. | 30 | itself orphaned, and starts determining the reference time with local |
45 | 31 | The default value of 6 will enable orphaned operation when there are | 31 | peers. A typical value is 6, which will enable orphaned operation |
46 | 32 | no stratum 6 servers or servers of a higher stratum available, which | 32 | when there are no stratum 6 servers or servers of a higher stratum |
47 | 33 | is two strata below most Internet NTP hosts. | 33 | available, which is two strata below most Internet NTP hosts. Set to |
48 | 34 | Set to 0 to disable orphan mode entirely. | 34 | 0 to disable orphan mode entirely. You must enable at least one peer |
49 | 35 | in order to use orphan mode, but four or more is recommended for best | ||
50 | 36 | results. | ||
51 | 35 | nagios_context: | 37 | nagios_context: |
52 | 36 | default: "juju" | 38 | default: "juju" |
53 | 37 | type: string | 39 | type: string |
54 | 38 | description: | | 40 | description: | |
55 | 39 | Used by the nrpe-external-master subordinate charm. | 41 | Used by the nrpe-external-master subordinate charm. |
57 | 40 | A string that will be prepended to instance name to set the host name | 42 | A string which will be prepended to instance name to set the host name |
58 | 41 | in nagios. So for instance the hostname would be something like: | 43 | in nagios. So for instance the hostname would be something like: |
59 | 42 | juju-myservice-0 | 44 | juju-myservice-0 |
60 | 43 | If you're running multiple environments with the same services in them | 45 | If you're running multiple environments with the same services in them |
61 | diff --git a/hooks/ntp_hooks.py b/hooks/ntp_hooks.py | |||
62 | index efde7ad..e9f537d 100755 | |||
63 | --- a/hooks/ntp_hooks.py | |||
64 | +++ b/hooks/ntp_hooks.py | |||
65 | @@ -1,21 +1,18 @@ | |||
66 | 1 | #!/usr/bin/python3 | 1 | #!/usr/bin/python3 |
67 | 2 | 2 | ||
68 | 3 | from charmhelpers.contrib.charmsupport import nrpe | 3 | from charmhelpers.contrib.charmsupport import nrpe |
69 | 4 | from charmhelpers.contrib.templating.jinja import render | ||
70 | 5 | from charmhelpers.core import hookenv, host, unitdata | 4 | from charmhelpers.core import hookenv, host, unitdata |
71 | 6 | import charmhelpers.fetch as fetch | 5 | import charmhelpers.fetch as fetch |
72 | 7 | import os | 6 | import os |
73 | 8 | import shutil | ||
74 | 9 | import sys | 7 | import sys |
75 | 10 | 8 | ||
76 | 9 | import ntp_implementation | ||
77 | 11 | import ntp_scoring | 10 | import ntp_scoring |
78 | 12 | 11 | ||
79 | 13 | NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins' | 12 | NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins' |
80 | 14 | 13 | ||
81 | 15 | NTP_CONF = '/etc/ntp.conf' | ||
82 | 16 | NTP_CONF_ORIG = '{}.orig'.format(NTP_CONF) | ||
83 | 17 | |||
84 | 18 | hooks = hookenv.Hooks() | 14 | hooks = hookenv.Hooks() |
85 | 15 | implementation = ntp_implementation.get_implementation() | ||
86 | 19 | 16 | ||
87 | 20 | 17 | ||
88 | 21 | def get_peer_sources(topN=6): | 18 | def get_peer_sources(topN=6): |
89 | @@ -65,9 +62,8 @@ def get_peer_sources(topN=6): | |||
90 | 65 | def install(): | 62 | def install(): |
91 | 66 | fetch.apt_update(fatal=True) | 63 | fetch.apt_update(fatal=True) |
92 | 67 | ntp_scoring.install_packages() | 64 | ntp_scoring.install_packages() |
96 | 68 | if ntp_scoring.get_virt_type() != 'container': | 65 | fetch.apt_install(implementation.packages_to_install(), fatal=True) |
97 | 69 | fetch.apt_install(["ntp"], fatal=True) | 66 | implementation.save_config() |
95 | 70 | shutil.copy(NTP_CONF, NTP_CONF_ORIG) | ||
98 | 71 | 67 | ||
99 | 72 | 68 | ||
100 | 73 | def get_sources(sources, iburst=True, source_list=None): | 69 | def get_sources(sources, iburst=True, source_list=None): |
101 | @@ -92,16 +88,20 @@ def get_sources(sources, iburst=True, source_list=None): | |||
102 | 92 | @hooks.hook('master-relation-departed') | 88 | @hooks.hook('master-relation-departed') |
103 | 93 | @hooks.hook('ntp-peers-relation-joined', | 89 | @hooks.hook('ntp-peers-relation-joined', |
104 | 94 | 'ntp-peers-relation-changed') | 90 | 'ntp-peers-relation-changed') |
106 | 95 | @host.restart_on_change({NTP_CONF: ['ntp']}) | 91 | @host.restart_on_change({implementation.config_file(): [implementation.service_name()]}) |
107 | 96 | def write_config(): | 92 | def write_config(): |
108 | 97 | ntp_scoring.install_packages() | 93 | ntp_scoring.install_packages() |
109 | 94 | |||
110 | 98 | if ntp_scoring.get_virt_type() == 'container': | 95 | if ntp_scoring.get_virt_type() == 'container': |
115 | 99 | host.service_stop('ntp') | 96 | is_container = 1 |
116 | 100 | host.service_pause('ntp') | 97 | else: |
117 | 101 | hookenv.close_port(123, protocol="UDP") | 98 | is_container = 0 |
114 | 102 | return | ||
118 | 103 | 99 | ||
120 | 104 | host.service_resume('ntp') | 100 | implementation.set_startup_options({ |
121 | 101 | 'is_container': is_container, | ||
122 | 102 | }) | ||
123 | 103 | |||
124 | 104 | host.service_resume(implementation.service_name()) | ||
125 | 105 | hookenv.open_port(123, protocol="UDP") | 105 | hookenv.open_port(123, protocol="UDP") |
126 | 106 | 106 | ||
127 | 107 | use_iburst = hookenv.config('use_iburst') | 107 | use_iburst = hookenv.config('use_iburst') |
128 | @@ -142,17 +142,17 @@ def write_config(): | |||
129 | 142 | kv.unset('auto_peer') | 142 | kv.unset('auto_peer') |
130 | 143 | 143 | ||
131 | 144 | if len(remote_sources) == 0 and len(remote_peers) == 0 and len(remote_pools) == 0: | 144 | if len(remote_sources) == 0 and len(remote_peers) == 0 and len(remote_pools) == 0: |
134 | 145 | # we have no peers/pools/servers; restore default ntp.conf provided by OS | 145 | # we have no peers/pools/servers; restore default config |
135 | 146 | shutil.copy(NTP_CONF_ORIG, NTP_CONF) | 146 | implementation.restore_config() |
136 | 147 | else: | 147 | else: |
137 | 148 | # otherwise, write our own configuration | 148 | # otherwise, write our own configuration |
145 | 149 | with open(NTP_CONF, "w") as ntpconf: | 149 | implementation.set_config({ |
146 | 150 | ntpconf.write(render(os.path.basename(NTP_CONF), { | 150 | 'is_container': is_container, |
147 | 151 | 'orphan_stratum': orphan_stratum, | 151 | 'orphan_stratum': orphan_stratum, |
148 | 152 | 'peers': remote_peers, | 152 | 'peers': remote_peers, |
149 | 153 | 'pools': remote_pools, | 153 | 'pools': remote_pools, |
150 | 154 | 'servers': remote_sources, | 154 | 'servers': remote_sources, |
151 | 155 | })) | 155 | }) |
152 | 156 | 156 | ||
153 | 157 | if hookenv.relation_ids('nrpe-external-master'): | 157 | if hookenv.relation_ids('nrpe-external-master'): |
154 | 158 | update_nrpe_config() | 158 | update_nrpe_config() |
155 | @@ -263,27 +263,32 @@ def hyperv_sync_status(): | |||
156 | 263 | 263 | ||
157 | 264 | @hooks.hook('update-status') | 264 | @hooks.hook('update-status') |
158 | 265 | def assess_status(): | 265 | def assess_status(): |
160 | 266 | version = fetch.get_upstream_version('ntp') | 266 | package = implementation.package_name() |
161 | 267 | version = fetch.get_upstream_version(package) | ||
162 | 267 | if version is not None: | 268 | if version is not None: |
163 | 268 | hookenv.application_version_set(version) | 269 | hookenv.application_version_set(version) |
164 | 269 | 270 | ||
170 | 270 | # create base status | 271 | # base status |
171 | 271 | if ntp_scoring.get_virt_type() == 'container': | 272 | status = package + ': ' |
172 | 272 | state = 'blocked' | 273 | |
173 | 273 | status = 'NTP not supported in containers: please configure on host' | 274 | # append service status |
174 | 274 | elif host.service_running('ntp'): | 275 | if host.service_running(implementation.service_name()): |
175 | 275 | state = 'active' | 276 | state = 'active' |
177 | 276 | status = 'Ready' | 277 | status += 'Ready' |
178 | 277 | else: | 278 | else: |
179 | 278 | state = 'blocked' | 279 | state = 'blocked' |
181 | 279 | status = 'Not running' | 280 | status += 'Not running' |
182 | 281 | |||
183 | 282 | # append container status | ||
184 | 283 | if ntp_scoring.get_virt_type() == 'container': | ||
185 | 284 | status += ', time sync disabled in container' | ||
186 | 280 | 285 | ||
188 | 281 | # append Hyper-V status, if any | 286 | # append Hyper-V status |
189 | 282 | hyperv_status = hyperv_sync_status() | 287 | hyperv_status = hyperv_sync_status() |
190 | 283 | if hyperv_status is not None: | 288 | if hyperv_status is not None: |
191 | 284 | status += ', ' + hyperv_status | 289 | status += ', ' + hyperv_status |
192 | 285 | 290 | ||
194 | 286 | # append scoring status, if any | 291 | # append scoring status |
195 | 287 | # (don't force update of the score from update-status more than once a month) | 292 | # (don't force update of the score from update-status more than once a month) |
196 | 288 | max_age = 31 * 86400 | 293 | max_age = 31 * 86400 |
197 | 289 | scorestr = ntp_scoring.get_score_string(max_seconds=max_age) | 294 | scorestr = ntp_scoring.get_score_string(max_seconds=max_age) |
198 | diff --git a/hooks/ntp_implementation.py b/hooks/ntp_implementation.py | |||
199 | 290 | new file mode 100644 | 295 | new file mode 100644 |
200 | index 0000000..e565b0e | |||
201 | --- /dev/null | |||
202 | +++ b/hooks/ntp_implementation.py | |||
203 | @@ -0,0 +1,132 @@ | |||
204 | 1 | |||
205 | 2 | # Copyright (c) 2018 Canonical Ltd | ||
206 | 3 | # License: GPLv3 | ||
207 | 4 | # Author: Paul Gear | ||
208 | 5 | |||
209 | 6 | # NTP implementation details | ||
210 | 7 | |||
211 | 8 | import charmhelpers.contrib.templating.jinja as templating | ||
212 | 9 | import charmhelpers.core.host | ||
213 | 10 | import charmhelpers.osplatform | ||
214 | 11 | import os.path | ||
215 | 12 | import shutil | ||
216 | 13 | |||
217 | 14 | |||
218 | 15 | class NTPImplementation: | ||
219 | 16 | """Base class for NTP implementations.""" | ||
220 | 17 | |||
221 | 18 | def config_file(self): | ||
222 | 19 | raise NotImplementedError | ||
223 | 20 | |||
224 | 21 | def _config_file_backup(self): | ||
225 | 22 | return self.config_file() + ".bak" | ||
226 | 23 | |||
227 | 24 | def _config_file_orig(self): | ||
228 | 25 | return self.config_file() + ".orig" | ||
229 | 26 | |||
230 | 27 | def _config_file_template(self): | ||
231 | 28 | raise NotImplementedError | ||
232 | 29 | |||
233 | 30 | def package_name(self): | ||
234 | 31 | raise NotImplementedError | ||
235 | 32 | |||
236 | 33 | def packages_to_install(self): | ||
237 | 34 | return [self.package_name()] | ||
238 | 35 | |||
239 | 36 | def restore_config(self): | ||
240 | 37 | for path in [self._config_file_orig(), self._config_file_backup()]: | ||
241 | 38 | if os.path.exists(path): | ||
242 | 39 | shutil.copy(path, self.config_file()) | ||
243 | 40 | |||
244 | 41 | def save_config(self): | ||
245 | 42 | backup = self._config_file_backup() | ||
246 | 43 | if not os.path.exists(backup): | ||
247 | 44 | shutil.copy(self.config_file(), backup) | ||
248 | 45 | |||
249 | 46 | def service_name(self): | ||
250 | 47 | raise NotImplementedError | ||
251 | 48 | |||
252 | 49 | def set_config(self, config): | ||
253 | 50 | with open(self.config_file(), "w") as conffile: | ||
254 | 51 | conffile.write(templating.render(self._config_file_template(), config)) | ||
255 | 52 | |||
256 | 53 | def set_startup_options(self, config): | ||
257 | 54 | with open(self._startup_config_file(), "w") as startup: | ||
258 | 55 | startup.write(templating.render(self._startup_template_file(), config)) | ||
259 | 56 | |||
260 | 57 | def _startup_config_file(self): | ||
261 | 58 | raise NotImplementedError | ||
262 | 59 | |||
263 | 60 | def _startup_template_file(self): | ||
264 | 61 | raise NotImplementedError | ||
265 | 62 | |||
266 | 63 | |||
267 | 64 | class Chronyd(NTPImplementation): | ||
268 | 65 | |||
269 | 66 | def config_file(self): | ||
270 | 67 | return "/etc/chrony/chrony.conf" | ||
271 | 68 | |||
272 | 69 | def _config_file_orig(self): | ||
273 | 70 | return "/usr/share/chrony/chrony.conf" | ||
274 | 71 | |||
275 | 72 | def _config_file_template(self): | ||
276 | 73 | return "chrony.conf" | ||
277 | 74 | |||
278 | 75 | def package_name(self): | ||
279 | 76 | return "chrony" | ||
280 | 77 | |||
281 | 78 | def service_name(self): | ||
282 | 79 | return "chrony" | ||
283 | 80 | |||
284 | 81 | def _startup_config_file(self): | ||
285 | 82 | return "/etc/default/chrony" | ||
286 | 83 | |||
287 | 84 | def _startup_template_file(self): | ||
288 | 85 | return "chrony.default" | ||
289 | 86 | |||
290 | 87 | |||
291 | 88 | class NTPd(NTPImplementation): | ||
292 | 89 | |||
293 | 90 | def config_file(self): | ||
294 | 91 | return "/etc/ntp.conf" | ||
295 | 92 | |||
296 | 93 | def _config_file_template(self): | ||
297 | 94 | return "ntp.conf" | ||
298 | 95 | |||
299 | 96 | def package_name(self): | ||
300 | 97 | return "ntp" | ||
301 | 98 | |||
302 | 99 | def service_name(self): | ||
303 | 100 | return "ntp" | ||
304 | 101 | |||
305 | 102 | def _startup_config_file(self): | ||
306 | 103 | return "/etc/default/ntp" | ||
307 | 104 | |||
308 | 105 | def _startup_template_file(self): | ||
309 | 106 | return "ntp.default" | ||
310 | 107 | |||
311 | 108 | |||
312 | 109 | def get_implementation(implementation_name=None): | ||
313 | 110 | """Select the appropriate NTP implementation for this platform.""" | ||
314 | 111 | if implementation_name is not None and implementation_name.lower() == 'chrony': | ||
315 | 112 | return Chronyd() | ||
316 | 113 | if implementation_name is not None and implementation_name.lower() == 'ntpd': | ||
317 | 114 | return NTPd() | ||
318 | 115 | |||
319 | 116 | # anything else: auto mode | ||
320 | 117 | platform = charmhelpers.osplatform.get_platform() | ||
321 | 118 | version = float(charmhelpers.core.host.lsb_release()['DISTRIB_RELEASE']) | ||
322 | 119 | |||
323 | 120 | if platform == 'ubuntu': | ||
324 | 121 | if version > 18: | ||
325 | 122 | # Ubuntu 18.04 or later: use chronyd | ||
326 | 123 | return Chronyd() | ||
327 | 124 | else: | ||
328 | 125 | # Ubuntu 17.10 or earlier: use ntpd | ||
329 | 126 | return NTPd() | ||
330 | 127 | elif platform == 'centos': | ||
331 | 128 | # CentOS: use chronyd | ||
332 | 129 | return Chronyd() | ||
333 | 130 | else: | ||
334 | 131 | # something else: use ntpd | ||
335 | 132 | return NTPd() | ||
336 | diff --git a/templates/chrony.conf b/templates/chrony.conf | |||
337 | 0 | new file mode 100644 | 133 | new file mode 100644 |
338 | index 0000000..6e559cc | |||
339 | --- /dev/null | |||
340 | +++ b/templates/chrony.conf | |||
341 | @@ -0,0 +1,58 @@ | |||
342 | 1 | # juju-generated chrony configuration | ||
343 | 2 | |||
344 | 3 | # This directive specify the location of the file containing ID/key pairs for | ||
345 | 4 | # NTP authentication. | ||
346 | 5 | keyfile /etc/chrony/chrony.keys | ||
347 | 6 | |||
348 | 7 | # This directive specify the file into which chronyd will store the rate | ||
349 | 8 | # information. | ||
350 | 9 | driftfile /var/lib/chrony/chrony.drift | ||
351 | 10 | |||
352 | 11 | # Enable logging | ||
353 | 12 | log tracking measurements statistics rtc refclocks | ||
354 | 13 | |||
355 | 14 | # Log files location. | ||
356 | 15 | logdir /var/log/chrony | ||
357 | 16 | |||
358 | 17 | # Step the system clock instead of slewing it if the adjustment is larger than | ||
359 | 18 | # one second, but only in the first three clock updates. | ||
360 | 19 | makestep 1 3 | ||
361 | 20 | |||
362 | 21 | # Stop bad estimates upsetting machine clock. | ||
363 | 22 | maxupdateskew 100.0 | ||
364 | 23 | |||
365 | 24 | {%- if is_container == 0 %} | ||
366 | 25 | |||
367 | 26 | # This directive enables kernel synchronisation (every 11 minutes) of the | ||
368 | 27 | # real-time clock. Note that it can't be used along with the 'rtcfile' directive. | ||
369 | 28 | rtcsync | ||
370 | 29 | {%- endif %} | ||
371 | 30 | |||
372 | 31 | # Save state about peers & servers | ||
373 | 32 | dumpdir /var/lib/chrony | ||
374 | 33 | |||
375 | 34 | {%- if orphan_stratum > 0 %} | ||
376 | 35 | |||
377 | 36 | # Orphan mode enabled | ||
378 | 37 | local stratum {{ orphan_stratum }} orphan | ||
379 | 38 | {%- endif %} | ||
380 | 39 | |||
381 | 40 | # allow any host to use us as an NTP server | ||
382 | 41 | # (use juju unexpose to prevent access) | ||
383 | 42 | allow | ||
384 | 43 | |||
385 | 44 | # PEERS | ||
386 | 45 | {%- for peer in peers %} | ||
387 | 46 | peer {{ peer.name }} {{ peer.iburst }} | ||
388 | 47 | {%- endfor %} | ||
389 | 48 | |||
390 | 49 | # POOLS | ||
391 | 50 | {%- for pool in pools %} | ||
392 | 51 | pool {{ pool.name }} {{ pool.iburst }} | ||
393 | 52 | {%- endfor %} | ||
394 | 53 | |||
395 | 54 | # SERVERS | ||
396 | 55 | {%- for server in servers %} | ||
397 | 56 | server {{ server.name }} {{ server.iburst }} | ||
398 | 57 | {%- endfor %} | ||
399 | 58 | |||
400 | diff --git a/templates/chrony.default b/templates/chrony.default | |||
401 | 0 | new file mode 100644 | 59 | new file mode 100644 |
402 | index 0000000..aaaf90e | |||
403 | --- /dev/null | |||
404 | +++ b/templates/chrony.default | |||
405 | @@ -0,0 +1,13 @@ | |||
406 | 1 | # juju-generated chrony startup config | ||
407 | 2 | |||
408 | 3 | # This is a configuration file for /etc/init.d/chrony and | ||
409 | 4 | # /lib/systemd/system/chrony.service; it allows you to pass various options to | ||
410 | 5 | # the chrony daemon without editing the init script or service file. | ||
411 | 6 | |||
412 | 7 | # Options to pass to chrony. | ||
413 | 8 | {%- if is_container == 1 %} | ||
414 | 9 | DAEMON_OPTS="-x" | ||
415 | 10 | {%- else %} | ||
416 | 11 | DAEMON_OPTS="" | ||
417 | 12 | {%- endif %} | ||
418 | 13 | |||
419 | diff --git a/templates/ntp.conf b/templates/ntp.conf | |||
420 | index d5674c7..1a38ecf 100644 | |||
421 | --- a/templates/ntp.conf | |||
422 | +++ b/templates/ntp.conf | |||
423 | @@ -1,28 +1,46 @@ | |||
424 | 1 | # juju-generated ntp configuration | 1 | # juju-generated ntp configuration |
425 | 2 | tinker panic 0 | 2 | tinker panic 0 |
426 | 3 | driftfile /var/lib/ntp/ntp.drift | 3 | driftfile /var/lib/ntp/ntp.drift |
427 | 4 | |||
428 | 4 | statsdir /var/log/ntpstats | 5 | statsdir /var/log/ntpstats |
429 | 5 | statistics loopstats peerstats clockstats sysstats | 6 | statistics loopstats peerstats clockstats sysstats |
430 | 6 | filegen loopstats file loopstats type day enable | 7 | filegen loopstats file loopstats type day enable |
431 | 7 | filegen peerstats file peerstats type day enable | 8 | filegen peerstats file peerstats type day enable |
432 | 8 | filegen clockstats file clockstats type day enable | 9 | filegen clockstats file clockstats type day enable |
433 | 9 | filegen sysstats file sysstats type day enable | 10 | filegen sysstats file sysstats type day enable |
434 | 11 | |||
435 | 10 | restrict -4 default kod notrap nomodify nopeer noquery limited | 12 | restrict -4 default kod notrap nomodify nopeer noquery limited |
436 | 11 | restrict -6 default kod notrap nomodify nopeer noquery limited | 13 | restrict -6 default kod notrap nomodify nopeer noquery limited |
437 | 12 | restrict source notrap nomodify noquery | 14 | restrict source notrap nomodify noquery |
438 | 13 | restrict 127.0.0.1 | 15 | restrict 127.0.0.1 |
439 | 14 | restrict ::1 | 16 | restrict ::1 |
441 | 15 | {% if orphan_stratum > 0 %} | 17 | |
442 | 18 | {%- if is_container == 1 %} | ||
443 | 19 | # running in a container - time adjustments disabled | ||
444 | 20 | disable kernel | ||
445 | 21 | {%- endif %} | ||
446 | 22 | |||
447 | 23 | {%- if orphan_stratum > 0 %} | ||
448 | 24 | |||
449 | 25 | # orphan mode enabled | ||
450 | 16 | tos orphan {{ orphan_stratum }} | 26 | tos orphan {{ orphan_stratum }} |
457 | 17 | {% endif %} | 27 | {%- endif %} |
458 | 18 | {% for peer in peers %}restrict {{ peer.name }} kod notrap nomodify | 28 | |
453 | 19 | {% endfor %} | ||
454 | 20 | # SERVERS | ||
455 | 21 | {% for server in servers %}server {{ server.name }} {{ server.iburst }} | ||
456 | 22 | {% endfor %} | ||
459 | 23 | # PEERS | 29 | # PEERS |
462 | 24 | {% for peer in peers %}peer {{ peer.name }} {{ peer.iburst }} | 30 | {%- for peer in peers %} |
463 | 25 | {% endfor %} | 31 | restrict {{ peer.name }} kod notrap nomodify |
464 | 32 | {%- endfor %} | ||
465 | 33 | {%- for peer in peers %} | ||
466 | 34 | peer {{ peer.name }} {{ peer.iburst }} | ||
467 | 35 | {%- endfor %} | ||
468 | 36 | |||
469 | 26 | # POOLS | 37 | # POOLS |
472 | 27 | {% for pool in pools %}pool {{ pool.name }} {{ pool.iburst }} | 38 | {%- for pool in pools %} |
473 | 28 | {% endfor %} | 39 | pool {{ pool.name }} {{ pool.iburst }} |
474 | 40 | {%- endfor %} | ||
475 | 41 | |||
476 | 42 | # SERVERS | ||
477 | 43 | {%- for server in servers %} | ||
478 | 44 | server {{ server.name }} {{ server.iburst }} | ||
479 | 45 | {%- endfor %} | ||
480 | 46 | |||
481 | diff --git a/templates/ntp.default b/templates/ntp.default | |||
482 | 29 | new file mode 100644 | 47 | new file mode 100644 |
483 | index 0000000..f84c389 | |||
484 | --- /dev/null | |||
485 | +++ b/templates/ntp.default | |||
486 | @@ -0,0 +1,2 @@ | |||
487 | 1 | # juju-generated ntp startup configuration | ||
488 | 2 | NTPD_OPTS='-g' |
Nice changes, thanks