1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #2872 from tima/fuzzy-match-localhost-127

Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa
This commit is contained in:
Michael DeHaan 2013-05-11 11:15:49 -07:00
commit e4e6616169

View file

@ -246,10 +246,15 @@ class Inventory(object):
return self._hosts_cache[hostname]
def _get_host(self, hostname):
for group in self.groups:
for host in group.get_hosts():
if hostname == host.name:
if hostname in ['localhost','127.0.0.1']:
for host in self.get_group('all').get_hosts():
if host.name in ['localhost', '127.0.0.1']:
return host
else:
for group in self.groups:
for host in group.get_hosts():
if hostname == host.name:
return host
return None
def get_group(self, groupname):