Merge pull request #1508 from dhozac/host_vars-in-include

Return original string for non-matched vars
This commit is contained in:
Michael DeHaan 2012-11-01 16:32:48 -07:00
commit 4cc1ff4b21
2 changed files with 8 additions and 1 deletions

View file

@ -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)):

View file

@ -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