@ -648,10 +648,6 @@ class Templar:
self . _cached_result = { }
self . _basedir = loader . get_basedir ( ) if loader else ' ./ '
# flags to determine whether certain failures during templating
# should result in fatal errors being raised
self . _fail_on_lookup_errors = True
self . _fail_on_filter_errors = True
self . _fail_on_undefined_errors = C . DEFAULT_UNDEFINED_VAR_BEHAVIOR
environment_class = AnsibleNativeEnvironment if USE_JINJA2_NATIVE else AnsibleEnvironment
@ -807,14 +803,13 @@ class Templar:
if fail_on_undefined is None :
fail_on_undefined = self . _fail_on_undefined_errors
try :
if convert_bare :
variable = self . _convert_bare_variable ( variable )
if isinstance ( variable , string_types ) :
result = variable
if not self . is_possibly_template ( variable ) :
return variable
if self . is_possibly_template ( variable ) :
# Check to see if the string we are trying to render is just referencing a single
# var. In this case we don't want to accidentally change the type of the variable
# to a string by using the jinja template renderer. We just want to pass it.
@ -841,9 +836,10 @@ class Templar:
) . encode ( ' utf-8 ' )
)
sha1_hash = variable_hash . hexdigest ( ) + options_hash . hexdigest ( )
if cache and sha1_hash in self . _cached_result :
result = self . _cached_result [ sha1_hash ]
else :
if sha1_hash in self . _cached_result :
return self . _cached_result [ sha1_hash ]
result = self . do_template (
variable ,
preserve_trailing_newlines = preserve_trailing_newlines ,
@ -864,9 +860,7 @@ class Templar:
result = eval_results [ 0 ]
if unsafe :
result = wrap_var ( result )
else :
# FIXME: if the safe_eval raised an error, should we do something with it?
pass
# we only cache in the case where we have a single variable
# name, to make sure we're not putting things which may otherwise
@ -903,12 +897,6 @@ class Templar:
else :
return variable
except AnsibleFilterError :
if self . _fail_on_filter_errors :
raise
else :
return variable
def is_template ( self , data ) :
''' lets us know if data has a template '''
if isinstance ( data , string_types ) :
@ -1022,7 +1010,6 @@ class Templar:
raise e
except AnsibleLookupError as e :
# lookup handled error but still decided to bail
if self . _fail_on_lookup_errors :
msg = ' Lookup failed but the error is being ignored: %s ' % to_native ( e )
if errors == ' warn ' :
display . warning ( msg )
@ -1033,7 +1020,6 @@ class Templar:
return [ ] if wantlist else None
except Exception as e :
# errors not handled by lookup
if self . _fail_on_lookup_errors :
msg = u " An unhandled exception occurred while running the lookup plugin ' %s ' . Error was a %s , original message: %s " % \
( name , type ( e ) , to_text ( e ) )
if errors == ' warn ' :