mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge branch 'devel' of https://github.com/danslimmon/ansible into danslimmon-devel
This commit is contained in:
commit
cf3c58d6ef
2 changed files with 12 additions and 0 deletions
|
@ -235,6 +235,10 @@ class Inventory(object):
|
||||||
a tuple of (start, stop) or None
|
a tuple of (start, stop) or None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Do not parse regexes for enumeration info
|
||||||
|
if pattern.startswith('~'):
|
||||||
|
return (pattern, None)
|
||||||
|
|
||||||
# The regex used to match on the range, which can be [x] or [x-y].
|
# The regex used to match on the range, which can be [x] or [x-y].
|
||||||
pattern_re = re.compile("^(.*)\[([-]?[0-9]+)(?:(?:-)([0-9]+))?\](.*)$")
|
pattern_re = re.compile("^(.*)\[([-]?[0-9]+)(?:(?:-)([0-9]+))?\](.*)$")
|
||||||
m = pattern_re.match(pattern)
|
m = pattern_re.match(pattern)
|
||||||
|
|
|
@ -274,6 +274,14 @@ class TestInventory(unittest.TestCase):
|
||||||
print "EXPECTED=%s" % sorted(expected_hosts)
|
print "EXPECTED=%s" % sorted(expected_hosts)
|
||||||
assert sorted(hosts) == sorted(expected_hosts)
|
assert sorted(hosts) == sorted(expected_hosts)
|
||||||
|
|
||||||
|
def test_regex_grouping(self):
|
||||||
|
inventory = self.simple_inventory()
|
||||||
|
hosts = inventory.list_hosts("~(cer[a-z]|berc)(erus00[13])")
|
||||||
|
expected_hosts = ['cerberus001', 'cerberus003']
|
||||||
|
print "HOSTS=%s" % sorted(hosts)
|
||||||
|
print "EXPECTED=%s" % sorted(expected_hosts)
|
||||||
|
assert sorted(hosts) == sorted(expected_hosts)
|
||||||
|
|
||||||
def test_complex_enumeration(self):
|
def test_complex_enumeration(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue