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

Return original string for non-matched vars
pull/1648/head
Michael DeHaan 12 years ago
commit 4cc1ff4b21

@ -187,7 +187,10 @@ def varReplaceWithItems(basedir, varname, vars):
if not m: if not m:
return varname return varname
if m['start'] == 0 and m['end'] == len(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: else:
return template(basedir, varname, vars) return template(basedir, varname, vars)
elif isinstance(varname, (list, tuple)): elif isinstance(varname, (list, tuple)):

@ -324,6 +324,10 @@ class TestUtils(unittest.TestCase):
res = ansible.utils.varReplaceWithItems(None, template, vars) res = ansible.utils.varReplaceWithItems(None, template, vars)
assert sorted(res) == sorted(vars['alphas']) assert sorted(res) == sorted(vars['alphas'])
template = '${data.nonexisting}'
res = ansible.utils.varReplaceWithItems(None, template, vars)
assert res == template
##################################### #####################################
### Template function tests ### Template function tests

Loading…
Cancel
Save