simplified pattern matching, fixed ungrouped (#22523)
* simplified pattern matching, fixed ungrouped
ungrouped was ignored for patterns, now it is usable again
* even simpler
(cherry picked from commit 273786d0bd
)
This commit is contained in:
parent
c9ea993c88
commit
eccfcf020c
1 changed files with 7 additions and 16 deletions
|
@ -473,25 +473,16 @@ class Inventory(object):
|
|||
"""
|
||||
|
||||
results = []
|
||||
hostnames = set()
|
||||
|
||||
def __append_host_to_results(host):
|
||||
if host.name not in hostnames:
|
||||
hostnames.add(host.name)
|
||||
if host.name not in results:
|
||||
if not host.implicit:
|
||||
results.append(host)
|
||||
|
||||
groups = self.get_groups()
|
||||
for group in groups.values():
|
||||
if pattern == 'all':
|
||||
if self._match(group.name, pattern):
|
||||
for host in group.get_hosts():
|
||||
if host.implicit:
|
||||
continue
|
||||
__append_host_to_results(host)
|
||||
else:
|
||||
if self._match(group.name, pattern) and group.name not in ('all', 'ungrouped'):
|
||||
for host in group.get_hosts():
|
||||
if host.implicit:
|
||||
continue
|
||||
__append_host_to_results(host)
|
||||
else:
|
||||
matching_hosts = self._match_list(group.get_hosts(), 'name', pattern)
|
||||
|
|
Loading…
Reference in a new issue