#NEWLINE# @ operation #NEWLINE# def template( state , host , template_filename , remote_filename , user = None , group = None , mode = None , **data ) : #NEWLINE# #INDENT# '\n    Generate a template and write it to the remote system.\n\n    + template_filename: local template 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# if state . deploy_dir : #NEWLINE# #INDENT# template_filename = path . join ( state . deploy_dir , template_filename ) #NEWLINE# #UNINDENT# if isinstance ( template_filename , six . string_types ) : #NEWLINE# #INDENT# template_file = get_file ( template_filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# template_file = template_filename #NEWLINE# #UNINDENT# template = get_template ( template_file . read ( ) ) #NEWLINE# data [ 'host' ] = host #NEWLINE# data [ 'inventory' ] = state . inventory #NEWLINE# output = template . render ( data ) #NEWLINE# output_file = six . StringIO ( output ) #NEWLINE# return put ( state , host , output_file , remote_filename , user = user , group = group , mode = mode , add_deploy_dir = False )