2
votes

my requirement is moving files to remote host using ansible playbook.

my ansible script

---
- hosts: webservers
  remote_user: root
  tasks:
     - copy: src=/home/bu/Bilal/site dest=/tmp owner=root group=root mode=777

when run playbook it has moved the file to remote.

when I have ran playbook again it will overwrite the whole folder again. I am looking, what are the files I have modified that files only get overwrite because my folder size is too large its taking so much time even single file change.

1

1 Answers

2
votes

Take a look at the Synchronize module:

Uses rsync to make synchronizing file paths in your playbooks quick and easy.

Example:

- name: Sync files
  synchronize:
    src: "{{ conf.dev_path }}/"
    dest: "{{ conf.host_path }}"
    delete: yes
    rsync_opts:
      - "--exclude=.*"