mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa.
This commit is contained in:
parent
8ef18c2f98
commit
20bf5f130d
1 changed files with 8 additions and 3 deletions
|
@ -246,10 +246,15 @@ class Inventory(object):
|
||||||
return self._hosts_cache[hostname]
|
return self._hosts_cache[hostname]
|
||||||
|
|
||||||
def _get_host(self, hostname):
|
def _get_host(self, hostname):
|
||||||
for group in self.groups:
|
if hostname in ['localhost','127.0.0.1']:
|
||||||
for host in group.get_hosts():
|
for host in self.get_group('all').get_hosts():
|
||||||
if hostname == host.name:
|
if host.name in ['localhost', '127.0.0.1']:
|
||||||
return host
|
return host
|
||||||
|
else:
|
||||||
|
for group in self.groups:
|
||||||
|
for host in group.get_hosts():
|
||||||
|
if hostname == host.name:
|
||||||
|
return host
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_group(self, groupname):
|
def get_group(self, groupname):
|
||||||
|
|
Loading…
Reference in a new issue