diff options
| author | Petr Spacek <pspacek@redhat.com> | 2015-11-10 11:22:43 +0100 |
|---|---|---|
| committer | Jan Cholasta <jcholast@redhat.com> | 2015-12-01 10:19:25 +0100 |
| commit | 45d9d4e8ae524cdc91effc05ce3fe1c06cfb750e (patch) | |
| tree | e8139e3c8e2d8a73774760524e4831d3c5e1d4cb | |
| parent | fa62480c73ccb860c8c8b4cd110b0782eb4883d5 (diff) | |
| download | freeipa-45d9d4e8ae524cdc91effc05ce3fe1c06cfb750e.tar.gz freeipa-45d9d4e8ae524cdc91effc05ce3fe1c06cfb750e.tar.xz freeipa-45d9d4e8ae524cdc91effc05ce3fe1c06cfb750e.zip | |
ipa-dns-install offer IP addresses from resolv.conf as default forwarders
In non-interactive more option --auto-forwarders can be used to do the
same. --forward option can be used to supply additional IP addresses.
https://fedorahosted.org/freeipa/ticket/5438
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
| -rw-r--r-- | ipaserver/install/dns.py | 12 | ||||
| -rw-r--r-- | ipaserver/install/installutils.py | 7 | ||||
| -rw-r--r-- | ipaserver/install/server/common.py | 14 | ||||
| -rw-r--r-- | ipaserver/install/server/install.py | 7 | ||||
| -rw-r--r-- | ipaserver/install/server/replicainstall.py | 7 |
5 files changed, 39 insertions, 8 deletions
diff --git a/ipaserver/install/dns.py b/ipaserver/install/dns.py index 615bd557b..6c8e952f4 100644 --- a/ipaserver/install/dns.py +++ b/ipaserver/install/dns.py @@ -2,8 +2,11 @@ # Copyright (C) 2015 FreeIPA Contributors see COPYING for license # +from __future__ import absolute_import from __future__ import print_function +# absolute import is necessary because IPA module dns clashes with python-dns +from dns import resolver import sys from subprocess import CalledProcessError @@ -230,8 +233,13 @@ def install_check(standalone, replica, options, hostname): if options.no_forwarders: dns_forwarders = () - elif options.forwarders: - dns_forwarders = options.forwarders + elif options.forwarders or options.auto_forwarders: + if options.forwarders: + dns_forwarders = options.forwarders + else: + dns_forwarders = [] + if options.auto_forwarders: + dns_forwarders += resolver.get_default_resolver().nameservers elif standalone or not replica: dns_forwarders = read_dns_forwarders() diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 489d03bda..156c8a5eb 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -282,6 +282,13 @@ def read_ip_addresses(): def read_dns_forwarders(): addrs = [] if ipautil.user_input("Do you want to configure DNS forwarders?", True): + print("Following DNS servers are configured in /etc/resolv.conf: %s" % + ", ".join(resolver.get_default_resolver().nameservers)) + if ipautil.user_input("Do you want to configure these servers as DNS " + "forwarders?", True): + addrs = resolver.default_resolver.nameservers[:] + print("All DNS servers from /etc/resolv.conf were added. You can " + "enter additional addresses now:") while True: ip = ipautil.user_input("Enter an IP address for a DNS forwarder, " "or press Enter to skip", allow_empty=True) diff --git a/ipaserver/install/server/common.py b/ipaserver/install/server/common.py index 93c95dd8e..82c2c9eac 100644 --- a/ipaserver/install/server/common.py +++ b/ipaserver/install/server/common.py @@ -167,6 +167,11 @@ class BaseServerDNS(common.Installable, core.Group, core.Composite): cli_name='forwarder', ) + auto_forwarders = Knob( + bool, False, + description="Use DNS forwarders configured in /etc/resolv.conf", + ) + no_forwarders = Knob( bool, False, description="Do not add any DNS forwarders, use root servers instead", @@ -395,6 +400,10 @@ class BaseServer(common.Installable, common.Interactive, core.Composite): raise RuntimeError( "You cannot specify a --forwarder option without the " "--setup-dns option") + if self.dns.auto_forwarders: + raise RuntimeError( + "You cannot specify a --auto-forwarders option without " + "the --setup-dns option") if self.dns.no_forwarders: raise RuntimeError( "You cannot specify a --no-forwarders option without the " @@ -415,6 +424,10 @@ class BaseServer(common.Installable, common.Interactive, core.Composite): raise RuntimeError( "You cannot specify a --forwarder option together with " "--no-forwarders") + elif self.dns.auto_forwarders and self.dns.no_forwarders: + raise RuntimeError( + "You cannot specify a --auto-forwarders option together with " + "--no-forwarders") elif self.dns.reverse_zones and self.dns.no_reverse: raise RuntimeError( "You cannot specify a --reverse-zone option together with " @@ -441,6 +454,7 @@ class BaseServer(common.Installable, common.Interactive, core.Composite): self.skip_schema_check = self.ca.skip_schema_check self.forwarders = self.dns.forwarders + self.auto_forwarders = self.dns.auto_forwarders self.no_forwarders = self.dns.no_forwarders self.reverse_zones = self.dns.reverse_zones self.no_reverse = self.dns.no_reverse diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py index bd07793bb..a181d8c54 100644 --- a/ipaserver/install/server/install.py +++ b/ipaserver/install/server/install.py @@ -1267,10 +1267,11 @@ class Server(BaseServer): "and -a options") if self.setup_dns: #pylint: disable=no-member - if not self.dns.forwarders and not self.dns.no_forwarders: + if (not self.dns.forwarders and not self.dns.no_forwarders + and not self.dns.auto_forwarders): raise RuntimeError( - "You must specify at least one --forwarder option or " - "--no-forwarders option") + "You must specify at least one of --forwarder, " + "--auto-forwarders, or --no-forwarders options") if self.idmax < self.idstart: raise RuntimeError( diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py index e6d96bbe6..eac42dab2 100644 --- a/ipaserver/install/server/replicainstall.py +++ b/ipaserver/install/server/replicainstall.py @@ -1199,10 +1199,11 @@ class Replica(BaseServer): if self.setup_dns: #pylint: disable=no-member - if not self.dns.forwarders and not self.dns.no_forwarders: + if (not self.dns.forwarders and not self.dns.no_forwarders + and not self.dns.auto_forwarders): raise RuntimeError( - "You must specify at least one --forwarder option or " - "--no-forwarders option") + "You must specify at least one of --forwarder, " + "--auto-forwarders, or --no-forwarders options") self.password = self.dm_password |
