Make listify respect the global setting for undefined variables.

(Fixes #9008.)

With credit to jimi-c for the initial pass in this commit:
b18bd6b98e
This commit is contained in:
Rob Howard 2014-10-08 13:44:59 +11:00
parent bbd9921dbd
commit 2769098fe7
2 changed files with 13 additions and 1 deletions

View file

@ -48,6 +48,7 @@ import sys
import json
import subprocess
import contextlib
import jinja2.exceptions
from vault import VaultLib
@ -1419,11 +1420,13 @@ def listify_lookup_plugin_terms(terms, basedir, inject):
# if not already a list, get ready to evaluate with Jinja2
# not sure why the "/" is in above code :)
try:
new_terms = template.template(basedir, "{{ %s }}" % terms, inject)
new_terms = template.template(basedir, terms, inject, convert_bare=True, fail_on_undefined=C.DEFAULT_UNDEFINED_VAR_BEHAVIOR)
if isinstance(new_terms, basestring) and "{{" in new_terms:
pass
else:
terms = new_terms
except jinja2.exceptions.UndefinedError, e:
raise errors.AnsibleUndefinedVariable('undefined variable in items: %s' % e)
except:
pass