Allows whitespaces around assignment operators

when defining group variables
This commit is contained in:
Junegunn Choi 2012-12-14 20:43:29 +09:00
commit daf797804b
3 changed files with 15 additions and 3 deletions

View file

@ -24,6 +24,7 @@ from ansible.inventory.expand_hosts import detect_range
from ansible.inventory.expand_hosts import expand_hostname_range
from ansible import errors
import shlex
import re
class InventoryParser(object):
"""
@ -167,5 +168,8 @@ class InventoryParser(object):
if line.find("=") == -1:
raise errors.AnsibleError("variables assigned to group must be in key=value form")
else:
(k,v) = line.split("=",1)
group.set_variable(k,v)
(k, v) = [e.strip() for e in line.split("=", 1)]
if re.match(r"^(['\"]).*\1$", v):
group.set_variable(k, re.sub(r"^['\"]|['\"]$", '', v))
else:
group.set_variable(k, v)