mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Allows whitespaces around assignment operators
when defining group variables
This commit is contained in:
parent
23f2a7fc7e
commit
daf797804b
3 changed files with 15 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue