From 9303e3d0912e60b2069f7c5bad6b816ed8b033ef Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slaznick@redhat.com>
Date: Wed, 5 Apr 2017 09:57:44 +0200
Subject: [PATCH] replicainstall: better client install exception handling
The exception handling of client install inside replica installation
was rather promiscuous, hungrily eating any possible exception thrown
at it. Scoped down the try-except block and reduced its promiscuity.
This change should improve the future development experience debugging
this part of the code.
https://pagure.io/freeipa/issue/6183
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
---
ipaserver/install/server/replicainstall.py | 83 +++++++++++++++---------------
1 file changed, 41 insertions(+), 42 deletions(-)
diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py
index 383932b39b9ee99a7a5ce3275a5a7e02581b85b7..aa8e67f60b8abe591d55a907c409b584c74d4541 100644
--- a/ipaserver/install/server/replicainstall.py
+++ b/ipaserver/install/server/replicainstall.py
@@ -895,52 +895,51 @@ def install_check(installer):
def ensure_enrolled(installer):
- # Call client install script
- service.print_msg("Configuring client side components")
+ args = [paths.IPA_CLIENT_INSTALL, "--unattended", "--no-ntp"]
+ stdin = None
+ nolog = []
+
+ if installer.domain_name:
+ args.extend(["--domain", installer.domain_name])
+ if installer.server:
+ args.extend(["--server", installer.server])
+ if installer.realm_name:
+ args.extend(["--realm", installer.realm_name])
+ if installer.host_name:
+ args.extend(["--hostname", installer.host_name])
+
+ if installer.password:
+ args.extend(["--password", installer.password])
+ nolog.append(installer.password)
+ else:
+ if installer.admin_password:
+ # Always set principal if password was set explicitly,
+ # the password itself gets passed directly via stdin
+ args.extend(["--principal", installer.principal or "admin"])
+ stdin = installer.admin_password
+ if installer.keytab:
+ args.extend(["--keytab", installer.keytab])
+
+ if installer.no_dns_sshfp:
+ args.append("--no-dns-sshfp")
+ if installer.ssh_trust_dns:
+ args.append("--ssh-trust-dns")
+ if installer.no_ssh:
+ args.append("--no-ssh")
+ if installer.no_sshd:
+ args.append("--no-sshd")
+ if installer.mkhomedir:
+ args.append("--mkhomedir")
+ if installer.force_join:
+ args.append("--force-join")
+
try:
+ # Call client install script
+ service.print_msg("Configuring client side components")
installer._enrollment_performed = True
-
- args = [paths.IPA_CLIENT_INSTALL, "--unattended", "--no-ntp"]
- stdin = None
- nolog = []
-
- if installer.domain_name:
- args.extend(["--domain", installer.domain_name])
- if installer.server:
- args.extend(["--server", installer.server])
- if installer.realm_name:
- args.extend(["--realm", installer.realm_name])
- if installer.host_name:
- args.extend(["--hostname", installer.host_name])
-
- if installer.password:
- args.extend(["--password", installer.password])
- nolog.append(installer.password)
- else:
- if installer.admin_password:
- # Always set principal if password was set explicitly,
- # the password itself gets passed directly via stdin
- args.extend(["--principal", installer.principal or "admin"])
- stdin = installer.admin_password
- if installer.keytab:
- args.extend(["--keytab", installer.keytab])
-
- if installer.no_dns_sshfp:
- args.append("--no-dns-sshfp")
- if installer.ssh_trust_dns:
- args.append("--ssh-trust-dns")
- if installer.no_ssh:
- args.append("--no-ssh")
- if installer.no_sshd:
- args.append("--no-sshd")
- if installer.mkhomedir:
- args.append("--mkhomedir")
- if installer.force_join:
- args.append("--force-join")
-
ipautil.run(args, stdin=stdin, nolog=nolog, redirect_output=True)
print()
- except Exception:
+ except ipautil.CalledProcessError:
raise ScriptError("Configuration of client side components failed!")
--
2.12.2