mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
parent
fa62480c73
commit
45d9d4e8ae
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user