mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #12001 from amenonsen/10034-rebase
double the speed of loading a 10k host inventory file (#10034 rebase)
This commit is contained in:
commit
b1e8493e7d
1 changed files with 8 additions and 7 deletions
|
@ -351,7 +351,7 @@ class Inventory(object):
|
|||
pattern = pattern.replace("!","").replace("&", "")
|
||||
|
||||
def __append_host_to_results(host):
|
||||
if host not in results and host.name not in hostnames:
|
||||
if host.name not in hostnames:
|
||||
hostnames.add(host.name)
|
||||
results.append(host)
|
||||
|
||||
|
@ -413,12 +413,13 @@ class Inventory(object):
|
|||
if host.name in self.LOCALHOST_ALIASES:
|
||||
return host
|
||||
return self._create_implicit_localhost(hostname)
|
||||
else:
|
||||
for group in self.groups:
|
||||
for host in group.get_hosts():
|
||||
if hostname == host.name:
|
||||
return host
|
||||
return None
|
||||
matching_host = None
|
||||
for group in self.groups:
|
||||
for host in group.get_hosts():
|
||||
if hostname == host.name:
|
||||
matching_host = host
|
||||
self._hosts_cache[host.name] = host
|
||||
return matching_host
|
||||
|
||||
def get_group(self, groupname):
|
||||
for group in self.groups:
|
||||
|
|
Loading…
Reference in a new issue