From 8de73c1590de048eb6cfc3c56acfe737ca78b8a9 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 15 May 2020 09:24:47 +0200 Subject: [PATCH] Check for freeipa-server-dns package early The ``--setup-dns`` knob and interactive installer now check for presence of freeipa-server-dns early and stop the installer with an error. ``` $ ipa-server-install ... Do you want to configure integrated DNS (BIND)? [no]: yes Integrated DNS requires 'freeipa-server-dns' package The ipa-server-install command failed. See /var/log/ipaserver-install.log for more information ``` ``` $ ipa-server-install --setup-dns Usage: ipa-server-install [options] ipa-server-install: error: option setup-dns: Integrated DNS requires 'freeipa-server-dns' package The ipa-server-install command failed. ``` Fixes: https://pagure.io/freeipa/issue/7577 Signed-off-by: Christian Heimes Reviewed-By: Rob Crittenden --- ipaserver/install/dns.py | 12 +++++++++--- ipaserver/install/server/__init__.py | 5 +++++ ipaserver/install/server/install.py | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ipaserver/install/dns.py b/ipaserver/install/dns.py index 9f08e86f9..132d89f22 100644 --- a/ipaserver/install/dns.py +++ b/ipaserver/install/dns.py @@ -111,14 +111,20 @@ def _disable_dnssec(): conn.update_entry(entry) +def package_check(exception): + if not os.path.isfile(paths.IPA_DNS_INSTALL): + raise exception( + "Integrated DNS requires '%s' package" + % constants.IPA_DNS_PACKAGE_NAME + ) + + def install_check(standalone, api, replica, options, hostname): global ip_addresses global reverse_zones fstore = sysrestore.FileStore(paths.SYSRESTORE) - if not os.path.isfile(paths.IPA_DNS_INSTALL): - raise RuntimeError("Integrated DNS requires '%s' package" % - constants.IPA_DNS_PACKAGE_NAME) + package_check(RuntimeError) # when installing first DNS instance we need to check zone overlap if replica or standalone: diff --git a/ipaserver/install/server/__init__.py b/ipaserver/install/server/__init__.py index 21396e1ac..20b519a44 100644 --- a/ipaserver/install/server/__init__.py +++ b/ipaserver/install/server/__init__.py @@ -280,6 +280,11 @@ class ServerInstallInterface(ServerCertificateInstallInterface, ) setup_dns = enroll_only(setup_dns) + @setup_dns.validator + def setup_dns(self, value): + if value: + dns.package_check(ValueError) + idstart = knob( int, random.randint(1, 10000) * 200000, description="The starting value for the IDs range (default random)", diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py index afce0d73a..b53c58e2a 100644 --- a/ipaserver/install/server/install.py +++ b/ipaserver/install/server/install.py @@ -463,6 +463,7 @@ def install_check(installer): if not options.setup_dns and installer.interactive: if ipautil.user_input("Do you want to configure integrated DNS " "(BIND)?", False): + dns.package_check(ScriptError) options.setup_dns = True print("")