how do i copy files and sub folders recursively from one location to another location on remote machine by using ansible?

0 votes
[web]
server1
server2
main.yaml
- hosts: web
tasks:
- name: copy files on remote machine
  synchronize:
   src: /home/anil/anilfolder/
dest: /home/anil/anilbackup/
delegate_to:  "{{ inventory_hostname }}"

i wrote like above. but sometime i got synchronizes error. is any other alternative way to copy files and folders from one location to another location on remote machine.please give the solution as soon as possible

Jun 24 in Ansible by anil

edited Jun 24 by Kalgi 63 views
You're trying to copy a folder from one location to another right? You can achieve the same without using synchronize.
please give  one example if it has another solution

1 answer to this question.

0 votes

Try this:

- hosts: web
  tasks:
  - name: Ansible copy files from a directory to remote server
    copy:
      src:/home/anil/anilfolder/
      dest:/home/anil/anilbackup/
answered Jun 24 by Kalgi
• 37,320 points
by using above playbook,copy the files from source server to destination server.

but my requirement is copy files from one folder to another folder on remote server.

Related Questions In Ansible

0 votes
1 answer

Ansible playbbok to copy files from one node to another remote node

You can create a playbook for copying ...READ MORE

answered Jan 16 in Ansible by Danica
156 views
0 votes
1 answer

Ansible playbook for moving files from one node to another remote node

The best way to do this is: copy ...READ MORE

answered Jan 16 in Ansible by Nigya

edited Jan 18 by Vardhan 661 views
0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

One loop over multiple Ansible tasks

With_items has unfortunately stopped but it’s coming ...READ MORE

answered Jul 23, 2018 in Ansible by Kalgi
• 37,320 points
551 views