@ -38,9 +38,20 @@ class ActionModule(ActionBase):
source = self . _task . args . get ( ' src ' , None )
source = self . _task . args . get ( ' src ' , None )
dest = self . _task . args . get ( ' dest ' , None )
dest = self . _task . args . get ( ' dest ' , None )
copy = boolean ( self . _task . args . get ( ' copy' , Tru e) )
remote_sr c = boolean ( self . _task . args . get ( ' remote_src' , Fals e) )
creates = self . _task . args . get ( ' creates ' , None )
creates = self . _task . args . get ( ' creates ' , None )
# "copy" is deprecated in favor of "remote_src".
if ' copy ' in self . _task . args :
# They are mutually exclusive.
if ' remote_src ' in self . _task . args :
result [ ' failed ' ] = True
result [ ' msg ' ] = " parameters are mutually exclusive: ( ' copy ' , ' remote_src ' ) "
return result
# We will take the information from copy and store it in
# the remote_src var to use later in this file.
remote_src = not boolean ( self . _task . args . get ( ' copy ' ) )
if source is None or dest is None :
if source is None or dest is None :
result [ ' failed ' ] = True
result [ ' failed ' ] = True
result [ ' msg ' ] = " src (or content) and dest are required "
result [ ' msg ' ] = " src (or content) and dest are required "
@ -66,7 +77,7 @@ class ActionModule(ActionBase):
dest = self . _remote_expand_user ( dest ) # CCTODO: Fix path for Windows hosts.
dest = self . _remote_expand_user ( dest ) # CCTODO: Fix path for Windows hosts.
source = os . path . expanduser ( source )
source = os . path . expanduser ( source )
if copy :
if not remote_src :
try :
try :
source = self . _loader . get_real_file ( self . _find_needle ( ' files ' , source ) )
source = self . _loader . get_real_file ( self . _find_needle ( ' files ' , source ) )
except AnsibleError as e :
except AnsibleError as e :
@ -87,7 +98,7 @@ class ActionModule(ActionBase):
self . _remove_tmp_path ( tmp )
self . _remove_tmp_path ( tmp )
return result
return result
if copy :
if not remote_src :
# transfer the file to a remote tmp location
# transfer the file to a remote tmp location
tmp_src = self . _connection . _shell . join_path ( tmp , ' source ' )
tmp_src = self . _connection . _shell . join_path ( tmp , ' source ' )
self . _transfer_file ( source , tmp_src )
self . _transfer_file ( source , tmp_src )
@ -95,7 +106,7 @@ class ActionModule(ActionBase):
# handle diff mode client side
# handle diff mode client side
# handle check mode client side
# handle check mode client side
if copy :
if not remote_src :
# fix file permissions when the copy is done as a different user
# fix file permissions when the copy is done as a different user
self . _fixup_perms ( ( tmp , tmp_src ) , remote_user )
self . _fixup_perms ( ( tmp , tmp_src ) , remote_user )
# Build temporary module_args.
# Build temporary module_args.