return empty host list when pattern is empty

fixes #37894

(cherry picked from commit 2e852fcd6d)
pull/39358/merge
Brian Coca 7 years ago committed by Brian Coca
parent 19ab7b4b64
commit b595c6254f

@ -0,0 +1,2 @@
bugfixes:
- return empty list if host pattern is empty https://github.com/ansible/ansible/pull/37931

@ -330,17 +330,20 @@ class InventoryManager(object):
or applied subsets or applied subsets
""" """
hosts = []
# Check if pattern already computed # Check if pattern already computed
if isinstance(pattern, list): if isinstance(pattern, list):
pattern_hash = u":".join(pattern) pattern_hash = u":".join(pattern)
else: else:
pattern_hash = pattern pattern_hash = pattern
if pattern_hash:
if not ignore_limits and self._subset: if not ignore_limits and self._subset:
pattern_hash += ":%s" % to_native(self._subset) pattern_hash += u":%s" % to_text(self._subset, errors='surrogate_or_strict')
if not ignore_restrictions and self._restriction: if not ignore_restrictions and self._restriction:
pattern_hash += ":%s" % to_native(self._restriction) pattern_hash += u":%s" % to_text(self._restriction, errors='surrogate_or_strict')
if pattern_hash not in self._hosts_patterns_cache: if pattern_hash not in self._hosts_patterns_cache:

Loading…
Cancel
Save