From c23eda82c2c16e5a2c3820b6d0ffbd70b0a325a2 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 7 Jan 2013 18:20:09 +0100 Subject: [PATCH] Allow pattern[0] to address a single node Replaces erroring out on it and requiring the abysmal pattern[0-0] instead. --- lib/ansible/inventory/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index e13bb2d346b..55dbd921c03 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -165,10 +165,11 @@ class Inventory(object): return (pattern, None) (first, rest) = pattern.split("[") rest = rest.replace("]","") - if not "-" in rest: - raise errors.AnsibleError("invalid pattern: %s" % pattern) - (left, right) = rest.split("-",1) - return (first, (left, right)) + if "-" in rest: + (left, right) = rest.split("-",1) + return (first, (left, right)) + else: + return (first, (rest, rest)) def _apply_ranges(self, pat, hosts): """