summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kupka <dkupka@redhat.com>2016-11-28 15:56:30 +0100
committerDavid Kupka <dkupka@redhat.com>2017-01-05 10:45:30 +0100
commita15fdea615fa4e1153fbbed234113a235135572e (patch)
tree23087b12e9f233916ef1c1d3ef511f926e230745
parenta5fb5f2da1be158cde585a087aaf97eca6218dd7 (diff)
downloadfreeipa-a15fdea615fa4e1153fbbed234113a235135572e.tar.gz
freeipa-a15fdea615fa4e1153fbbed234113a235135572e.tar.xz
freeipa-a15fdea615fa4e1153fbbed234113a235135572e.zip
installer: Stop adding distro-specific NTP servers into ntp.conf
Distribution packaged ntpd has servers preconfigured in ntp.conf so there's no point in trying to add them again during FreeIPA server installation. Also fix the code to always put fudge line right after the local server line as required by ntpd. https://fedorahosted.org/freeipa/ticket/6486 Reviewed-By: Petr Spacek <pspacek@redhat.com>
-rw-r--r--ipaserver/install/ntpinstance.py51
1 files changed, 8 insertions, 43 deletions
diff --git a/ipaserver/install/ntpinstance.py b/ipaserver/install/ntpinstance.py
index 716eb0809..f30c1f2ed 100644
--- a/ipaserver/install/ntpinstance.py
+++ b/ipaserver/install/ntpinstance.py
@@ -20,7 +20,6 @@
from ipaserver.install import service
from ipaserver.install import sysupgrade
-from ipapython import ipautil
from ipaplatform.constants import constants
from ipaplatform.paths import paths
from ipapython.ipa_log_manager import root_logger
@@ -60,65 +59,31 @@ class NTPInstance(service.Service):
self.fstore.backup_file(paths.NTP_CONF)
self.fstore.backup_file(paths.SYSCONFIG_NTPD)
- # We use the OS variable to point it towards either the rhel
- # or fedora pools. Other distros should be added in the future
- # or we can get our own pool.
- os = ""
- if ipautil.file_exists(paths.ETC_FEDORA_RELEASE):
- os = "fedora"
- elif ipautil.file_exists(paths.ETC_REDHAT_RELEASE):
- os = "rhel"
-
- srv_vals = []
- srv_vals.append("0.%s.pool.ntp.org" % os)
- srv_vals.append("1.%s.pool.ntp.org" % os)
- srv_vals.append("2.%s.pool.ntp.org" % os)
- srv_vals.append("3.%s.pool.ntp.org" % os)
- srv_vals.append("127.127.1.0")
+ local_srv = "127.127.1.0"
fudge = ["fudge", "127.127.1.0", "stratum", "10"]
#read in memory, change it, then overwrite file
- file_changed = False
- fudge_present = False
ntpconf = []
fd = open(paths.NTP_CONF, "r")
for line in fd:
opt = line.split()
- if len(opt) < 1:
+ if len(opt) < 2:
ntpconf.append(line)
continue
- if opt[0] == "server":
- match = False
- for srv in srv_vals:
- if opt[1] == srv:
- match = True
- break
- if match:
- srv_vals.remove(srv)
- else:
- file_changed = True
- line = ""
+ if opt[0] == "server" and opt[1] == local_srv:
+ line = ""
elif opt[0] == "fudge":
- if opt[0:4] == fudge[0:4]:
- fudge_present = True
- else:
- file_changed = True
- line = ""
+ line = ""
ntpconf.append(line)
- if file_changed or len(srv_vals) != 0 or not fudge_present:
- fd = open(paths.NTP_CONF, "w")
+ with open(paths.NTP_CONF, "w") as fd:
for line in ntpconf:
fd.write(line)
fd.write("\n### Added by IPA Installer ###\n")
- if len(srv_vals) != 0:
- for srv in srv_vals:
- fd.write("server "+srv+" iburst\n")
- if not fudge_present:
- fd.write("fudge 127.127.1.0 stratum 10\n")
- fd.close()
+ fd.write("server {} iburst\n".format(local_srv))
+ fd.write("{}\n".format(' '.join(fudge)))
#read in memory, find OPTIONS, check/change it, then overwrite file
needopts = [ {'val':'-x', 'need':True},