mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Merge pull request #4351 from 2m/leading-range-fix
Allow leading ranges in the inventory host entries.
This commit is contained in:
@@ -294,6 +294,16 @@ class TestInventory(unittest.TestCase):
|
||||
expected_hosts=['host1A','host2A','host1B','host2B']
|
||||
assert sorted(hosts) == sorted(expected_hosts)
|
||||
|
||||
def test_leading_range(self):
|
||||
i = Inventory(os.path.join(self.test_dir, 'inventory','test_leading_range'))
|
||||
hosts = i.list_hosts('test')
|
||||
expected_hosts=['1.host','2.host','A.host','B.host']
|
||||
assert sorted(hosts) == sorted(expected_hosts)
|
||||
|
||||
hosts2 = i.list_hosts('test2')
|
||||
expected_hosts2=['1.host','2.host','3.host']
|
||||
assert sorted(hosts2) == sorted(expected_hosts2)
|
||||
|
||||
###################################################
|
||||
### Inventory API tests
|
||||
|
||||
|
||||
6
test/inventory/test_leading_range
Normal file
6
test/inventory/test_leading_range
Normal file
@@ -0,0 +1,6 @@
|
||||
[test]
|
||||
[1:2].host
|
||||
[A:B].host
|
||||
|
||||
[test2] # comment
|
||||
[1:3].host
|
||||
Reference in New Issue
Block a user