Add ::1 where we see 127.0.0.1, for better ipv6 support

Fixes #5764
pull/11305/head
James Cammarata 9 years ago
parent c3c398cffe
commit 90445ee67d

@ -372,7 +372,7 @@ class Inventory(object):
for host in matching_hosts:
__append_host_to_results(host)
if pattern in ["localhost", "127.0.0.1"] and len(results) == 0:
if pattern in ["localhost", "127.0.0.1", "::1"] and len(results) == 0:
new_host = self._create_implicit_localhost(pattern)
results.append(new_host)
return results
@ -408,9 +408,9 @@ class Inventory(object):
return self._hosts_cache[hostname]
def _get_host(self, hostname):
if hostname in ['localhost','127.0.0.1']:
if hostname in ['localhost', '127.0.0.1', '::1']:
for host in self.get_group('all').get_hosts():
if host.name in ['localhost', '127.0.0.1']:
if host.name in ['localhost', '127.0.0.1', '::1']:
return host
return self._create_implicit_localhost(hostname)
else:
@ -512,7 +512,7 @@ class Inventory(object):
""" return a list of hostnames for a pattern """
result = [ h for h in self.get_hosts(pattern) ]
if len(result) == 0 and pattern in ["localhost", "127.0.0.1"]:
if len(result) == 0 and pattern in ["localhost", "127.0.0.1", "::1"]:
result = [pattern]
return result

Loading…
Cancel
Save