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 <cheimes@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Christian Heimes 2020-05-15 09:24:47 +02:00
parent 1f82d281cc
commit 8de73c1590
3 changed files with 15 additions and 3 deletions

View File

@ -111,14 +111,20 @@ def _disable_dnssec():
conn.update_entry(entry) 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): def install_check(standalone, api, replica, options, hostname):
global ip_addresses global ip_addresses
global reverse_zones global reverse_zones
fstore = sysrestore.FileStore(paths.SYSRESTORE) fstore = sysrestore.FileStore(paths.SYSRESTORE)
if not os.path.isfile(paths.IPA_DNS_INSTALL): package_check(RuntimeError)
raise RuntimeError("Integrated DNS requires '%s' package" %
constants.IPA_DNS_PACKAGE_NAME)
# when installing first DNS instance we need to check zone overlap # when installing first DNS instance we need to check zone overlap
if replica or standalone: if replica or standalone:

View File

@ -280,6 +280,11 @@ class ServerInstallInterface(ServerCertificateInstallInterface,
) )
setup_dns = enroll_only(setup_dns) setup_dns = enroll_only(setup_dns)
@setup_dns.validator
def setup_dns(self, value):
if value:
dns.package_check(ValueError)
idstart = knob( idstart = knob(
int, random.randint(1, 10000) * 200000, int, random.randint(1, 10000) * 200000,
description="The starting value for the IDs range (default random)", description="The starting value for the IDs range (default random)",

View File

@ -463,6 +463,7 @@ def install_check(installer):
if not options.setup_dns and installer.interactive: if not options.setup_dns and installer.interactive:
if ipautil.user_input("Do you want to configure integrated DNS " if ipautil.user_input("Do you want to configure integrated DNS "
"(BIND)?", False): "(BIND)?", False):
dns.package_check(ScriptError)
options.setup_dns = True options.setup_dns = True
print("") print("")