Hosts file not updated when IP is passed as option

When an IPA server with unresolvable hostname is being installed,
a hostname record must be inserted to /etc/hosts or the
installation will fail. However, it is not inserted when IP
address is passed as an option (--ip-address) and not
interactively. This patch fixes this so that /etc/hosts
record is inserted in both cases.

https://fedorahosted.org/freeipa/ticket/2074
This commit is contained in:
Martin Kosek 2011-11-07 18:35:23 +01:00 committed by Rob Crittenden
parent 62c110a3b8
commit 0165a03694

View File

@ -754,10 +754,14 @@ def main():
# Check we have a public IP that is associated with the hostname
hostaddr = resolve_host(host_name)
ip_add_to_hosts = False
if hostaddr is not None:
ip = CheckedIPAddress(hostaddr, match_local=True)
else:
# hostname is not resolvable
ip = options.ip_address
ip_add_to_hosts = True
if ip is None:
print "Unable to resolve IP address for host name"
if options.unattended:
@ -772,11 +776,9 @@ def main():
ip = options.ip_address
ip_add_to_hosts = False
if ip is None:
ip = read_ip_address(host_name, fstore)
logging.debug("read ip_address: %s\n" % str(ip))
ip_add_to_hosts = True
ip_address = str(ip)