Commit 90445ee6 by James Cammarata

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

Fixes #5764
parent c3c398cf
...@@ -372,7 +372,7 @@ class Inventory(object): ...@@ -372,7 +372,7 @@ class Inventory(object):
for host in matching_hosts: for host in matching_hosts:
__append_host_to_results(host) __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) new_host = self._create_implicit_localhost(pattern)
results.append(new_host) results.append(new_host)
return results return results
...@@ -408,9 +408,9 @@ class Inventory(object): ...@@ -408,9 +408,9 @@ class Inventory(object):
return self._hosts_cache[hostname] return self._hosts_cache[hostname]
def _get_host(self, 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(): 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 host
return self._create_implicit_localhost(hostname) return self._create_implicit_localhost(hostname)
else: else:
...@@ -512,7 +512,7 @@ class Inventory(object): ...@@ -512,7 +512,7 @@ class Inventory(object):
""" return a list of hostnames for a pattern """ """ return a list of hostnames for a pattern """
result = [ h for h in self.get_hosts(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] result = [pattern]
return result return result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment