Resolve variable references inside variables

Fixes the case where variable x is '$y' and y is a dict(foo='bar') and
an attempt to access ${x.foo} is made.
This commit is contained in:
Daniel Hokka Zakrisson 2013-01-09 13:41:40 +01:00
commit 87b2378e22
2 changed files with 20 additions and 5 deletions

View file

@ -260,6 +260,17 @@ class TestUtils(unittest.TestCase):
res = ansible.utils.varReplace(None, template, vars)
assert res == 'test result'
def test_varReplace_var_complex_var(self):
vars = {
'x': '$y',
'y': {
'foo': 'result',
},
}
template = '${x.foo}'
res = ansible.utils.template(None, template, vars)
assert res == 'result'
def test_template_varReplace_iterated(self):
template = 'hello $who'
vars = {