@ -80,11 +80,12 @@ class ActionModule(ActionBase):
tmp_source = self . _loader . get_real_file ( source )
tmp_source = self . _loader . get_real_file ( source )
except AnsibleFileNotFound as e :
except AnsibleFileNotFound as e :
raise AnsibleActionFail ( " could not find src= %s , %s " % ( source , to_text ( e ) ) )
raise AnsibleActionFail ( " could not find src= %s , %s " % ( source , to_text ( e ) ) )
b_tmp_source = to_bytes ( tmp_source , errors = ' surrogate_or_strict ' )
# template the source data locally & get ready to transfer
# template the source data locally & get ready to transfer
try :
try :
with open ( tmp_source, ' r ' ) as f :
with open ( b_ tmp_source, ' r b ' ) as f :
template_data = to_text ( f . read ( ) )
template_data = to_text ( f . read ( ) , errors = ' surrogate_or_strict ' )
# set jinja2 internal search path for includes
# set jinja2 internal search path for includes
searchpath = task_vars . get ( ' ansible_search_path ' , [ ] )
searchpath = task_vars . get ( ' ansible_search_path ' , [ ] )
@ -124,7 +125,7 @@ class ActionModule(ActionBase):
except Exception as e :
except Exception as e :
raise AnsibleActionFail ( " %s : %s " % ( type ( e ) . __name__ , to_text ( e ) ) )
raise AnsibleActionFail ( " %s : %s " % ( type ( e ) . __name__ , to_text ( e ) ) )
finally :
finally :
self . _loader . cleanup_tmp_file ( tmp_source)
self . _loader . cleanup_tmp_file ( b_ tmp_source)
new_task = self . _task . copy ( )
new_task = self . _task . copy ( )
new_task . args . pop ( ' newline_sequence ' , None )
new_task . args . pop ( ' newline_sequence ' , None )
@ -138,7 +139,7 @@ class ActionModule(ActionBase):
try :
try :
result_file = os . path . join ( local_tempdir , os . path . basename ( source ) )
result_file = os . path . join ( local_tempdir , os . path . basename ( source ) )
with open ( result_file, ' wb ' ) as f :
with open ( to_bytes( result_file, errors = ' surrogate_or_strict ' ) , ' wb ' ) as f :
f . write ( to_bytes ( resultant , errors = ' surrogate_or_strict ' ) )
f . write ( to_bytes ( resultant , errors = ' surrogate_or_strict ' ) )
new_task . args . update (
new_task . args . update (
@ -157,7 +158,7 @@ class ActionModule(ActionBase):
shared_loader_obj = self . _shared_loader_obj )
shared_loader_obj = self . _shared_loader_obj )
result . update ( copy_action . run ( task_vars = task_vars ) )
result . update ( copy_action . run ( task_vars = task_vars ) )
finally :
finally :
shutil . rmtree ( local_tempdir)
shutil . rmtree ( to_bytes( local_tempdir, errors = ' surrogate_or_strict ' ) )
except AnsibleAction as e :
except AnsibleAction as e :
result . update ( e . result )
result . update ( e . result )