summaryrefslogtreecommitdiff
path: root/lib/ansible
diff options
context:
space:
mode:
authorJesse Keating <jesse.keating@rackspace.com>2014-03-03 13:23:27 -0800
committerJames Cammarata <jimi@sngx.net>2014-03-10 15:54:04 -0500
commitb14932465d768e634e500961434e6f05a033f2c8 (patch)
tree00f12e6e7493d3527001a0e2c3fb23163e9e9d3f /lib/ansible
parent5341040c0580007f3bf73007105a95555c8456e0 (diff)
downloadansible-b14932465d768e634e500961434e6f05a033f2c8.tar.gz
Avoid range selection on empty groups
This prevents a traceback when the group is empty. Fixes #6258
Diffstat (limited to 'lib/ansible')
-rw-r--r--lib/ansible/inventory/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py
index 67117919d0..8f74d5ea9e 100644
--- a/lib/ansible/inventory/__init__.py
+++ b/lib/ansible/inventory/__init__.py
@@ -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