mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Allow leading ranges in the inventory host entries.
This commit is contained in:
@@ -41,8 +41,7 @@ def detect_range(line = None):
|
||||
|
||||
Returnes True if the given line contains a pattern, else False.
|
||||
'''
|
||||
if (not line.startswith("[") and
|
||||
line.find("[") != -1 and
|
||||
if (line.find("[") != -1 and
|
||||
line.find(":") != -1 and
|
||||
line.find("]") != -1 and
|
||||
line.index("[") < line.index(":") < line.index("]")):
|
||||
|
||||
@@ -65,7 +65,7 @@ class InventoryParser(object):
|
||||
active_group_name = 'ungrouped'
|
||||
|
||||
for line in self.lines:
|
||||
if line.startswith("["):
|
||||
if line.startswith("[") and line.strip().endswith("]"):
|
||||
active_group_name = line.split(" #")[0].replace("[","").replace("]","").strip()
|
||||
if line.find(":vars") != -1 or line.find(":children") != -1:
|
||||
active_group_name = active_group_name.rsplit(":", 1)[0]
|
||||
|
||||
Reference in New Issue
Block a user