Skip to content
Snippets Groups Projects
Commit 42333296 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Handle multiple servers in ntp setup.

parent 8164c9f5
No related branches found
No related tags found
No related merge requests found
......@@ -5,12 +5,19 @@ import utils
def setup(interactive=True):
dir_path = utils.get_dir(__file__)
servers = ''
if utils.get_conf('NTP_SERVER'):
for server in utils.get_conf('NTP_SERVER').split(','):
if server.strip():
servers += 'server %s\n' % server.strip()
if not servers:
servers = 'server ntp.ubuntu.com\n'
cmds = [
# NTP
'DEBIAN_FRONTEND=noninteractive apt-get install -y ntp',
'echo "Replacing /etc/ntp.conf"',
dict(line='write', template='%s/ntp.conf' % dir_path, target='/etc/ntp.conf', params=(
('{{ NTP_SERVER }}', utils.get_conf('NTP_SERVER') or 'ntp.ubuntu.com'),
('{{ servers }}', servers),
)),
'service ntp restart',
]
......
......@@ -12,8 +12,7 @@ filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# Specify one or more NTP servers.
server {{ NTP_SERVER }}
{{ servers }}
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment