mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
@@ -73,14 +73,14 @@ class Inventory(object):
|
|||||||
hosts = {}
|
hosts = {}
|
||||||
patterns = pattern.replace(";",":").split(":")
|
patterns = pattern.replace(";",":").split(":")
|
||||||
|
|
||||||
for group in self.get_groups():
|
for (groupname, group) in self.get_groups().items():
|
||||||
for host in group.get_hosts():
|
for host in group.get_hosts():
|
||||||
for pat in patterns:
|
for pat in patterns:
|
||||||
if group.name == pat or pat == 'all' or self._match(host.name, pat):
|
if group.name == pat or pat == 'all' or self._match(host.name, pat):
|
||||||
if not self._restriction:
|
if not self._restriction:
|
||||||
hosts[host.name] = host
|
hosts[host.name] = host
|
||||||
if self._restriction and host.name in self._restriction:
|
if self._restriction and host.name in self._restriction:
|
||||||
hosts[host.name] = host
|
hosts[host.name] = host
|
||||||
return sorted(hosts.values(), key=lambda x: x.name)
|
return sorted(hosts.values(), key=lambda x: x.name)
|
||||||
|
|
||||||
def get_groups(self):
|
def get_groups(self):
|
||||||
@@ -88,8 +88,8 @@ class Inventory(object):
|
|||||||
|
|
||||||
def get_host(self, hostname):
|
def get_host(self, hostname):
|
||||||
for group in self.groups:
|
for group in self.groups:
|
||||||
for host in group.get_hosts():
|
for host in group.get_hosts():
|
||||||
if hostname == host.name:
|
if hostname == host.name:
|
||||||
return host
|
return host
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user