From a8d5e6bbfe03070925c85793ac898299d543a3d4 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 11 Aug 2020 10:47:05 -0400 Subject: [PATCH] Fall back to old server installation detection when needed If there is no installation section the the install pre-dated this new method of detecting a successful installation, fall back to that. https://pagure.io/freeipa/issue/8458 Reviewed-By: Florence Blanc-Renaud Reviewed-By: Stanislav Levin Reviewed-By: Alexander Bokovoy --- ipalib/facts.py | 31 ++++++++++++++++++++++++++++- ipaserver/install/installutils.py | 4 ---- ipaserver/install/server/install.py | 3 ++- ipaserver/install/server/upgrade.py | 7 +++++-- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ipalib/facts.py b/ipalib/facts.py index 5106fc2ac..d78c1a227 100644 --- a/ipalib/facts.py +++ b/ipalib/facts.py @@ -6,17 +6,46 @@ Facts about the installation """ +import logging import os from . import sysrestore from ipaplatform.paths import paths +logger = logging.getLogger(__name__) + +# Used to determine install status +IPA_MODULES = [ + 'httpd', 'kadmin', 'dirsrv', 'pki-tomcatd', 'install', 'krb5kdc', 'named'] + def is_ipa_configured(): """ Use the state to determine if IPA has been configured. """ sstore = sysrestore.StateFile(paths.SYSRESTORE) - return sstore.get_state('installation', 'complete') + if sstore.has_state('installation'): + return sstore.get_state('installation', 'complete') + + # Fall back to older method in case this is an existing installation + + installed = False + + fstore = sysrestore.FileStore(paths.SYSRESTORE) + + for module in IPA_MODULES: + if sstore.has_state(module): + logger.debug('%s is configured', module) + installed = True + else: + logger.debug('%s is not configured', module) + + if fstore.has_files(): + logger.debug('filestore has files') + installed = True + else: + logger.debug('filestore is tracking no files') + + return installed def is_ipa_client_configured(on_master=False): diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 583b1aca0..13baf494c 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -63,10 +63,6 @@ if six.PY3: logger = logging.getLogger(__name__) -# Used to determine install status -IPA_MODULES = [ - 'httpd', 'kadmin', 'dirsrv', 'pki-tomcatd', 'install', 'krb5kdc', 'named'] - class BadHostError(Exception): pass diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py index fc316bdc0..381d86114 100644 --- a/ipaserver/install/server/install.py +++ b/ipaserver/install/server/install.py @@ -37,13 +37,14 @@ from ipalib.util import ( validate_domain_name, no_matching_interface_for_ip_address_warning, ) +from ipalib.facts import IPA_MODULES from ipaserver.install import ( adtrust, adtrustinstance, bindinstance, ca, dns, dsinstance, httpinstance, installutils, kra, krbinstance, otpdinstance, custodiainstance, replication, service, sysupgrade, cainstance) from ipaserver.install.installutils import ( - IPA_MODULES, BadHostError, get_fqdn, get_server_ip_address, + BadHostError, get_fqdn, get_server_ip_address, load_pkcs12, read_password, verify_fqdn, update_hosts_file, validate_mask) diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py index 22d024b16..d532a1c0f 100644 --- a/ipaserver/install/server/upgrade.py +++ b/ipaserver/install/server/upgrade.py @@ -1486,8 +1486,11 @@ def upgrade_configuration(): fstore = sysrestore.FileStore(paths.SYSRESTORE) sstore = sysrestore.StateFile(paths.SYSRESTORE) - if is_ipa_configured() is None: - sstore.backup_state('installation', 'complete', True) + if not sstore.has_state('installation'): + if is_ipa_configured(): + sstore.backup_state('installation', 'complete', True) + else: + sstore.backup_state('installation', 'complete', False) fqdn = api.env.host