#NEWLINE# @ operation ( pipeline_facts = { #NEWLINE# #INDENT# 'file' : 'remote_filename' , #NEWLINE# 'sha1_file' : 'remote_filename' , #NEWLINE# #UNINDENT# } ) #NEWLINE# def put( state , host , local_filename , remote_filename , user = None , group = None , mode = None , add_deploy_dir = True ) : #NEWLINE# #INDENT# '\n    Copy a local file to the remote system.\n\n    + local_filename: local filename (or file-like object)\n    + remote_filename: remote filename\n    + user: user to own the files\n    + group: group to own the files\n    + mode: permissions of the files\n    ' #NEWLINE# mode = ensure_mode_int ( mode ) #NEWLINE# if isinstance ( local_filename , six . string_types ) : #NEWLINE# #INDENT# if ( state . deploy_dir and add_deploy_dir ) : #NEWLINE# #INDENT# local_filename = path . join ( state . deploy_dir , local_filename ) #NEWLINE# #UNINDENT# local_file = get_file ( local_filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# local_file = local_filename #NEWLINE# #UNINDENT# remote_file = host . fact . file ( remote_filename ) #NEWLINE# commands = [ ] #NEWLINE# if ( not remote_file ) : #NEWLINE# #INDENT# commands . append ( ( local_file , remote_filename ) ) #NEWLINE# if ( user or group ) : #NEWLINE# #INDENT# commands . append ( chown ( remote_filename , user , group ) ) #NEWLINE# #UNINDENT# if mode : #NEWLINE# #INDENT# commands . append ( chmod ( remote_filename , mode ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# local_sum = get_file_sha1 ( local_file ) #NEWLINE# remote_sum = host . fact . sha1_file ( remote_filename ) #NEWLINE# if ( local_sum != remote_sum ) : #NEWLINE# #INDENT# commands . append ( ( local_file , remote_filename ) ) #NEWLINE# if ( user or group ) : #NEWLINE# #INDENT# commands . append ( chown ( remote_filename , user , group ) ) #NEWLINE# #UNINDENT# if mode : #NEWLINE# #INDENT# commands . append ( chmod ( remote_filename , mode ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( mode and ( remote_file [ 'mode' ] != mode ) ) : #NEWLINE# #INDENT# commands . append ( chmod ( remote_filename , mode ) ) #NEWLINE# #UNINDENT# if ( ( user and ( remote_file [ 'user' ] != user ) ) or ( group and ( remote_file [ 'group' ] != group ) ) ) : #NEWLINE# #INDENT# commands . append ( chown ( remote_filename , user , group ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return commands