Adding method to ipa-server-upgrade to cleanup ntpd

Removing ntpd configuration files and entry from LDAP.

Add parameter and rename method for restoring forced time
services. Addressing some requests for change too.

Remove unused path for chrony-helper.

Resolves: https://pagure.io/freeipa/issue/7024
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Tibor Dudlák
2018-04-09 11:00:02 -04:00
committed by Rob Crittenden
parent 194518f11f
commit 5d9c749e83
7 changed files with 106 additions and 64 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ class Backup(admintool.AdminTool):
paths.IPA_CA_CRT,
paths.IPA_DEFAULT_CONF,
paths.DS_KEYTAB,
paths.NTP_CONF,
paths.CHRONY_CONF,
paths.SMB_CONF,
paths.SAMBA_KEYTAB,
paths.DOGTAG_ADMIN_P12,
+9 -8
View File
@@ -31,7 +31,7 @@ from ipalib.util import (
validate_domain_name,
no_matching_interface_for_ip_address_warning,
)
import ipaclient.install.ntpconf
import ipaclient.install.timeconf
from ipaserver.install import (
adtrust, bindinstance, ca, dns, dsinstance,
httpinstance, installutils, kra, krbinstance,
@@ -413,13 +413,13 @@ def install_check(installer):
if not options.no_ntp:
try:
ipaclient.install.ntpconf.check_timedate_services()
except ipaclient.install.ntpconf.NTPConflictingService as e:
print("WARNING: conflicting time&date synchronization service '%s'"
" will be disabled" % e.conflicting_service)
ipaclient.install.timeconf.check_timedate_services()
except ipaclient.install.timeconf.NTPConflictingService as e:
print("WARNING: conflicting time&date synchronization service '{}'"
" will be disabled".format(e.conflicting_service))
print("in favor of chronyd")
print("")
except ipaclient.install.ntpconf.NTPConfigurationError:
except ipaclient.install.timeconf.NTPConfigurationError:
pass
if not options.setup_dns and installer.interactive:
@@ -766,7 +766,8 @@ def install(installer):
# chrony will be handled here in uninstall() method as well by invoking
# the ipa-server-install --uninstall
if not options.no_ntp:
ipaclient.install.client.sync_time(options, fstore, sstore)
ipaclient.install.client.sync_time(
options, fstore, sstore, force=True)
if options.dirsrv_cert_files:
ds = dsinstance.DsInstance(fstore=fstore,
@@ -1119,7 +1120,7 @@ def uninstall(installer):
sstore._load()
ipaclient.install.ntpconf.restore_forced_chronyd(sstore)
ipaclient.install.timeconf.restore_forced_timeservices(sstore)
# Clean up group_exists (unused since IPA 2.2, not being set since 4.1)
sstore.restore_state("install", "group_exists")
+5 -5
View File
@@ -23,7 +23,7 @@ from pkg_resources import parse_version
import six
from ipaclient.install.ipachangeconf import IPAChangeConf
import ipaclient.install.ntpconf
import ipaclient.install.timeconf
from ipalib.install import certstore, sysrestore
from ipalib.install.kinit import kinit_keytab
from ipapython import ipaldap, ipautil
@@ -581,12 +581,12 @@ def common_check(no_ntp):
if not no_ntp:
try:
ipaclient.install.ntpconf.check_timedate_services()
except ipaclient.install.ntpconf.NTPConflictingService as e:
ipaclient.install.timeconf.check_timedate_services()
except ipaclient.install.timeconf.NTPConflictingService as e:
print("WARNING: conflicting time&date synchronization service "
"'{svc}' will\nbe disabled in favor of chronyd\n"
.format(svc=e.conflicting_service))
except ipaclient.install.ntpconf.NTPConfigurationError:
except ipaclient.install.timeconf.NTPConfigurationError:
pass
@@ -1391,7 +1391,7 @@ def install(installer):
if not promote and not options.no_ntp:
# in DL1, chrony is already installed
ipaclient.install.ntpconf.force_chrony(sstore)
ipaclient.install.timeconf.force_chrony(sstore)
try:
if promote:
+39
View File
@@ -20,6 +20,7 @@ from ipalib.install import certmonger, sysrestore
import SSSDConfig
import ipalib.util
import ipalib.errors
from ipaclient.install import timeconf
from ipaclient.install.client import sssd_enable_service
from ipaplatform import services
from ipaplatform.tasks import tasks
@@ -1593,6 +1594,41 @@ def enable_certauth(krb):
aug.close()
def ntpd_cleanup(fqdn, fstore):
sstore = sysrestore.StateFile(paths.SYSRESTORE)
timeconf.restore_forced_timeservices(sstore, 'ntpd')
if sstore.has_state('ntp'):
instance = services.service('ntpd', api)
sstore.restore_state(instance.service_name, 'enabled')
sstore.restore_state(instance.service_name, 'running')
sstore.restore_state(instance.service_name, 'step-tickers')
try:
instance.disable()
instance.stop()
except Exception as e:
logger.info("Service ntpd was not disabled or stopped")
ntpd_files = [paths.NTP_CONF, paths.NTP_STEP_TICKERS, paths.SYSCONFIG_NTPD]
for ntpd_file in ntpd_files:
try:
fstore.untrack_file(ntpd_file)
os.remove(ntpd_file)
except IOError:
logger.warning(
"No access to the %s, file could not be deleted.", ntpd_file)
except ValueError as e:
logger.warning("Error: %s", e)
connection = api.Backend.ldap2
try:
connection.delete_entry(DN(('cn', 'NTP'), ('cn', fqdn),
api.env.container_masters))
except ipalib.errors.NotFound:
logger.warning("Warning: NTP service entry was not found in LDAP.")
sysupgrade.set_upgrade_state('ntpd', 'ntpd_cleaned', True)
def upgrade_configuration():
"""
Execute configuration upgrade of the IPA services
@@ -1613,6 +1649,9 @@ def upgrade_configuration():
if not ds_running:
ds.start(ds_serverid)
if not sysupgrade.get_upgrade_state('ntpd', 'ntpd_cleaned'):
ntpd_cleanup(fqdn, fstore)
check_certs()
auto_redirect = find_autoredirect(fqdn)