Merge pull request #1508 from dhozac/host_vars-in-include
Return original string for non-matched vars
This commit is contained in:
commit
4cc1ff4b21
2 changed files with 8 additions and 1 deletions
|
@ -187,7 +187,10 @@ def varReplaceWithItems(basedir, varname, vars):
|
|||
if not m:
|
||||
return varname
|
||||
if m['start'] == 0 and m['end'] == len(varname):
|
||||
return varReplaceWithItems(basedir, m['replacement'], vars)
|
||||
if m['replacement'] is not None:
|
||||
return varReplaceWithItems(basedir, m['replacement'], vars)
|
||||
else:
|
||||
return varname
|
||||
else:
|
||||
return template(basedir, varname, vars)
|
||||
elif isinstance(varname, (list, tuple)):
|
||||
|
|
|
@ -324,6 +324,10 @@ class TestUtils(unittest.TestCase):
|
|||
res = ansible.utils.varReplaceWithItems(None, template, vars)
|
||||
assert sorted(res) == sorted(vars['alphas'])
|
||||
|
||||
template = '${data.nonexisting}'
|
||||
res = ansible.utils.varReplaceWithItems(None, template, vars)
|
||||
assert res == template
|
||||
|
||||
#####################################
|
||||
### Template function tests
|
||||
|
||||
|
|
Loading…
Reference in a new issue