mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Avoid range selection on empty groups
This prevents a traceback when the group is empty. Fixes #6258
This commit is contained in:
parent
07495ed29e
commit
0c2c37a47a
2 changed files with 11 additions and 0 deletions
|
@ -227,6 +227,12 @@ class Inventory(object):
|
|||
given a pattern like foo[0:5], where foo matches hosts, return the first 6 hosts
|
||||
"""
|
||||
|
||||
# If there are no hosts to select from, just return the
|
||||
# empty set. This prevents trying to do selections on an empty set.
|
||||
# issue#6258
|
||||
if not hosts:
|
||||
return hosts
|
||||
|
||||
(loose_pattern, limits) = self._enumeration_info(pat)
|
||||
if not limits:
|
||||
return hosts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue