Add --ntp-pool option to installers

FreeIPA Server and Client now support option for chrony
configuration --ntp-pool.
This option may be used with option --ntp-server.

Resolves: https://pagure.io/freeipa/issue/7024
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Tibor Dudlák 2018-03-12 13:36:12 +01:00 committed by Rob Crittenden
parent fb28dfff93
commit 194518f11f
2 changed files with 19 additions and 2 deletions

View File

@ -2367,7 +2367,8 @@ def sync_time(options, fstore, statestore):
ntp_servers = options.ntp_servers
if ntp_servers:
synced_time = ntpconf.configure_chrony(ntp_servers, fstore, statestore)
synced_time = ntpconf.configure_chrony(ntp_servers, options.ntp_pool,
fstore, statestore)
else:
synced_time = False
logger.warning("No SRV records of NTP servers found nor NTP server "
@ -3456,6 +3457,12 @@ class ClientInstallInterface(hostname_.HostNameInstallInterface,
)
ntp_servers = enroll_only(ntp_servers)
ntp_pool = knob(
str, None,
description="ntp server pool to use",
)
ntp_pool = enroll_only(ntp_pool)
no_ntp = knob(
None,
description="do not configure ntp",
@ -3556,6 +3563,10 @@ class ClientInstallInterface(hostname_.HostNameInstallInterface,
raise RuntimeError(
"--ntp-server cannot be used together with --no-ntp")
if self.ntp_pool and self.no_ntp:
raise RuntimeError(
"--ntp-pool cannot be used together with --no-ntp")
if self.no_nisdomain and self.nisdomain:
raise RuntimeError(
"--no-nisdomain cannot be used together with --nisdomain")

View File

@ -37,7 +37,8 @@ def __backup_config(path, fstore=None):
shutil.copy(path, "%s.ipasave" % (path))
def configure_chrony(ntp_servers, fstore=None, sysstore=None, debug=False):
def configure_chrony(ntp_servers, ntp_pool=None,
fstore=None, sysstore=None, debug=False):
if sysstore:
module = 'chrony'
sysstore.backup_state(module, "enabled",
@ -58,6 +59,11 @@ def configure_chrony(ntp_servers, fstore=None, sysstore=None, debug=False):
aug.remove('{}/server'.format(path))
aug.remove('{}/pool'.format(path))
aug.remove('{}/peer'.format(path))
if ntp_pool:
logger.debug("Setting server pool:")
logger.debug("'%s'", ntp_pool)
aug.set('{}/pool[last()+1]'.format(path), ntp_pool)
aug.set('{}/server[last()]/iburst'.format(path), None)
logger.debug("Setting time servers:")
for server in ntp_servers: