mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-11 19:04:02 -07:00
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:
parent
073fb21bcb
commit
87b2378e22
2 changed files with 20 additions and 5 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue