Simplify determining if IPA client configuration is complete

When asking the quesiton "is my IPA client configured?" right now
we look at whether the installation backed up any files and
/etc/ipa/default.conf exists.

Instead set a new state, installation, to True as soon as the
client installation finishes.

Unlike the server there is no upgrade process for clients so this
isn't going to be all that useful for quite some time unless that
changes because upgrading an existing install won't set this
to True.

https://pagure.io/freeipa/issue/8384

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Francois Cami <fcami@redhat.com>
This commit is contained in:
Rob Crittenden authored and Florence Blanc-Renaud committed 2020-08-06 14:11:27 +02:00
1 parent 0fa8686918
commit 4758db121e
2 files changed
+18 -6

No files matched your search

+17 -3
View File
@@ -266,13 +266,21 @@ def delete_ipa_domain():
"No access to the /etc/sssd/sssd.conf file.")
def is_ipa_client_installed(fstore, on_master=False):
def is_ipa_client_installed(on_master=False):
"""
Consider IPA client not installed if nothing is backed up
and default.conf file does not exist. If on_master is set to True,
the existence of default.conf file is not taken into consideration,
since it has been already created by ipa-server-install.
"""
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
installed = statestore.get_state('installation', 'complete')
if installed is not None:
return installed
# Fall back to the old detection
installed = (
fstore.has_files() or (
@@ -2086,7 +2094,7 @@ def install_check(options):
tasks.check_selinux_status()
if is_ipa_client_installed(fstore, on_master=options.on_master):
if is_ipa_client_installed(on_master=options.on_master):
logger.error("IPA client is already configured on this system.")
logger.info(
"If you want to reinstall the IPA client, uninstall it first "
@@ -2598,6 +2606,8 @@ def _install(options):
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
statestore.backup_state('installation', 'complete', False)
if not options.on_master:
# Try removing old principals from the keytab
purge_host_keytab(cli_realm)
@@ -3184,13 +3194,15 @@ def _install(options):
configure_nisdomain(
options=options, domain=cli_domain, statestore=statestore)
statestore.delete_state('installation', 'complete')
statestore.backup_state('installation', 'complete', True)
logger.info('Client configuration complete.')
def uninstall_check(options):
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
if not is_ipa_client_installed(fstore):
if not is_ipa_client_installed():
if options.on_master:
rval = SUCCESS
else:
@@ -3517,6 +3529,8 @@ def uninstall(options):
if fstore.has_files():
logger.error('Some files have not been restored, see %s',
paths.SYSRESTORE_INDEX)
statestore.delete_state('installation', 'complete')
has_state = False
for module in statestore.modules:
logger.error(
+1 -3
View File
@@ -42,7 +42,6 @@ from email.utils import make_msgid
from ipaclient.install.client import is_ipa_client_installed
from ipaplatform.paths import paths
from ipalib import api, errors
from ipalib.install import sysrestore
from ipapython import admintool, ipaldap
from ipapython.dn import DN
@@ -255,8 +254,7 @@ class EPN(admintool.AdminTool):
def run(self):
super(EPN, self).run()
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
if not is_ipa_client_installed(fstore):
if not is_ipa_client_installed():
logger.error("IPA client is not configured on this system.")
raise admintool.ScriptError()