|
|
@ -162,14 +162,14 @@ class Inventory(object):
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if not pattern_str.startswith('~'):
|
|
|
|
if not pattern_str.startswith('~'):
|
|
|
|
pattern = re.compile('^' + fnmatch.translate(pattern_str))
|
|
|
|
pattern = re.compile(fnmatch.translate(pattern_str))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
pattern = re.compile(pattern_str[1:])
|
|
|
|
pattern = re.compile(pattern_str[1:])
|
|
|
|
except Exception, e:
|
|
|
|
except Exception, e:
|
|
|
|
raise errors.AnsibleError('invalid host pattern: %s' % pattern_str)
|
|
|
|
raise errors.AnsibleError('invalid host pattern: %s' % pattern_str)
|
|
|
|
|
|
|
|
|
|
|
|
for item in items:
|
|
|
|
for item in items:
|
|
|
|
if pattern.search(getattr(item, item_attr)):
|
|
|
|
if pattern.match(getattr(item, item_attr)):
|
|
|
|
results.append(item)
|
|
|
|
results.append(item)
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|