From 90445ee67dad1e0a9d069e21780a4dc27fc304bf Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 17 Jun 2015 16:03:19 -0400 Subject: [PATCH] Add ::1 where we see 127.0.0.1, for better ipv6 support Fixes #5764 --- lib/ansible/inventory/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index a6e93b5655..de25c2ac32 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -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