How to copy local file to remote server using Ansible

Ansible copy module can be used to copy local file to remote server.

Let's see one sample snippet.

- name: Copy file
  copy:
    src: source 
    dest: destination
    owner: username
    group: groupname
    mode: permission

Where we need to replace,

source with full path to the source file
destination with full path to the destination folder
username with the username that which the remote file need to be owned
groupname with the groupname that which the remote file need to be owned
permission with the required file permissions in octet

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *