@ -616,6 +616,7 @@ class Templar:
if instance is not None :
wantlist = kwargs . pop ( ' wantlist ' , False )
allow_unsafe = kwargs . pop ( ' allow_unsafe ' , C . DEFAULT_ALLOW_UNSAFE_LOOKUPS )
errors = kwargs . pop ( ' errors ' , ' strict ' )
from ansible . utils . listify import listify_lookup_plugin_terms
loop_terms = listify_lookup_plugin_terms ( terms = args , templar = self , loader = self . _loader , fail_on_undefined = True , convert_bare = False )
@ -626,8 +627,14 @@ class Templar:
raise AnsibleUndefinedVariable ( e )
except Exception as e :
if self . _fail_on_lookup_errors :
raise AnsibleError ( " An unhandled exception occurred while running the lookup plugin ' %s ' . Error was a %s , "
" original message: %s " % ( name , type ( e ) , e ) )
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 ' :
display . warning ( msg )
elif errors == ' ignore ' :
display . log ( msg )
else :
raise AnsibleError ( to_native ( msg ) )
ran = None
if ran and not allow_unsafe :