summaryrefslogtreecommitdiffstats
path: root/install/tools/ipa-dns-install
diff options
context:
space:
mode:
authorDavid Kupka <dkupka@redhat.com>2014-08-27 13:50:21 +0200
committerMartin Kosek <mkosek@redhat.com>2014-09-26 17:54:18 +0200
commit947c7398edbcae29d74acea3b00968871bd4ce98 (patch)
tree0019656721da51ea39d2d63e0654c9b25d0ddd15 /install/tools/ipa-dns-install
parentf86618623964f9a97244ce08117c575b200a34af (diff)
downloadfreeipa-947c7398edbcae29d74acea3b00968871bd4ce98.tar.gz
freeipa-947c7398edbcae29d74acea3b00968871bd4ce98.tar.xz
freeipa-947c7398edbcae29d74acea3b00968871bd4ce98.zip
Detect and configure all usable IP addresses.
Find, verify and configure all IP addresses that can be used to reach the server FreeIPA is being installed on. Ignore some IP address only if user specifies subset of detected addresses using --ip-address option. This change simplyfies FreeIPA installation on multihomed and dual-stacked servers. https://fedorahosted.org/freeipa/ticket/3575 Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'install/tools/ipa-dns-install')
-rwxr-xr-xinstall/tools/ipa-dns-install71
1 files changed, 14 insertions, 57 deletions
diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index c9ea63ce3..ae60f211a 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -42,13 +42,16 @@ def parse_options():
sensitive=True, help="admin password")
parser.add_option("-d", "--debug", dest="debug", action="store_true",
default=False, help="print debugging information")
- parser.add_option("--ip-address", dest="ip_address",
+ parser.add_option("--ip-address", dest="ip_addresses",
+ default=[], action="append",
type="ip", ip_local=True, help="Master Server IP Address")
parser.add_option("--forwarder", dest="forwarders", action="append",
type="ip", help="Add a DNS forwarder")
parser.add_option("--no-forwarders", dest="no_forwarders", action="store_true",
default=False, help="Do not add any DNS forwarders, use root servers instead")
- parser.add_option("--reverse-zone", dest="reverse_zone", help="The reverse DNS zone to use")
+ parser.add_option("--reverse-zone", dest="reverse_zones",
+ default=[], action="append",
+ help="The reverse DNS zone to use")
parser.add_option("--no-reverse", dest="no_reverse", action="store_true",
default=False, help="Do not create new reverse DNS zone")
parser.add_option("--zonemgr", action="callback", callback=bindinstance.zonemgr_callback,
@@ -62,7 +65,7 @@ def parse_options():
if options.forwarders and options.no_forwarders:
parser.error("You cannot specify a --forwarder option together with --no-forwarders")
- elif options.reverse_zone and options.no_reverse:
+ elif options.reverse_zones and options.no_reverse:
parser.error("You cannot specify a --reverse-zone option together with --no-reverse")
if options.unattended:
@@ -130,46 +133,8 @@ def main():
except errors.ACIError:
sys.exit("Password is not valid!")
- # Check we have a public IP that is associated with the hostname
- if options.ip_address:
- ip = options.ip_address
- else:
- hostaddr = resolve_host(api.env.host)
- try:
- if len(hostaddr) > 1:
- print >> sys.stderr, "The server hostname resolves to more than one address:"
- for addr in hostaddr:
- print >> sys.stderr, " %s" % addr
-
- if options.ip_address:
- if str(options.ip_address) not in hostaddr:
- print >> sys.stderr, "Address passed in --ip-address did not match any resolved"
- print >> sys.stderr, "address!"
- sys.exit(1)
- print "Selected IP address:", str(options.ip_address)
- ip = options.ip_address
- else:
- if options.unattended:
- print >> sys.stderr, "Please use --ip-address option to specify the address"
- sys.exit(1)
- else:
- ip = read_ip_address(api.env.host, fstore)
- else:
- ip = hostaddr and ipautil.CheckedIPAddress(hostaddr[0], match_local=True)
- except Exception, e:
- print "Error: Invalid IP Address %s: %s" % (ip, e)
- ip = None
-
- if not ip:
- if options.unattended:
- sys.exit("Unable to resolve IP address for host name")
- else:
- ip = read_ip_address(api.env.host, fstore)
- ip_address = str(ip)
- root_logger.debug("will use ip_address: %s\n", ip_address)
-
- if options.reverse_zone and not bindinstance.verify_reverse_zone(options.reverse_zone, ip):
- sys.exit(1)
+ ip_addresses = get_server_ip_address(api.env.host, fstore,
+ options.unattended, True, options.ip_addresses)
if options.no_forwarders:
dns_forwarders = ()
@@ -186,19 +151,11 @@ def main():
ccache = krbV.default_context().default_ccache()
api.Backend.ldap2.connect(ccache)
- if options.reverse_zone:
- reverse_zone = bindinstance.normalize_zone(options.reverse_zone)
- else:
- reverse_zone = bindinstance.find_reverse_zone(ip)
- if reverse_zone is None and not options.no_reverse:
- if options.unattended:
- reverse_zone = util.get_reverse_zone_default(ip)
- elif bindinstance.create_reverse():
- reverse_zone = util.get_reverse_zone_default(ip)
- reverse_zone = bindinstance.read_reverse_zone(reverse_zone, ip)
+ reverse_zones = bindinstance.check_reverse_zones(ip_addresses,
+ options.reverse_zones, options, options.unattended, True)
- if reverse_zone is not None:
- print "Using reverse zone %s" % reverse_zone
+ if reverse_zones is not None:
+ print "Using reverse zone %s" % ', '.join(reverse_zones)
conf_ntp = ntpinstance.NTPInstance(fstore).is_enabled()
@@ -208,8 +165,8 @@ def main():
print "Please wait until the prompt is returned."
print ""
- bind.setup(api.env.host, ip_address, api.env.realm, api.env.domain,
- dns_forwarders, conf_ntp, reverse_zone, zonemgr=options.zonemgr)
+ bind.setup(api.env.host, ip_addresses, api.env.realm, api.env.domain,
+ dns_forwarders, conf_ntp, reverse_zones, zonemgr=options.zonemgr)
bind.create_instance()
# Restart http instance to make sure that python-dns has the right resolver