Commit 88964866 by Junegunn Choi

Adds comments on handling quoted group vars

parent daf79780
...@@ -169,7 +169,9 @@ class InventoryParser(object): ...@@ -169,7 +169,9 @@ class InventoryParser(object):
raise errors.AnsibleError("variables assigned to group must be in key=value form") raise errors.AnsibleError("variables assigned to group must be in key=value form")
else: else:
(k, v) = [e.strip() for e in line.split("=", 1)] (k, v) = [e.strip() for e in line.split("=", 1)]
# When the value is a single-quoted or double-quoted string
if re.match(r"^(['\"]).*\1$", v): if re.match(r"^(['\"]).*\1$", v):
# Unquote the string
group.set_variable(k, re.sub(r"^['\"]|['\"]$", '', v)) group.set_variable(k, re.sub(r"^['\"]|['\"]$", '', v))
else: else:
group.set_variable(k, v) group.set_variable(k, v)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment