# Copy files from Local to all Destinations using synchronize module fails.

**URL:** <https://forum.ansible.com/t/copy-files-from-local-to-all-destinations-using-synchronize-module-fails/31230>\
**Category:** Ansible Project\
**Created:** [September 9, 2019, 8:04am UTC](https://forum.ansible.com/t/copy-files-from-local-to-all-destinations-using-synchronize-module-fails/31230 "2019-09-09T08:04:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Easy\_King](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@Easy\_King](https://forum.ansible.com/u/Easy_King)\
**Post date:** [September 9, 2019, 8:04am UTC](https://forum.ansible.com/t/copy-files-from-local-to-all-destinations-using-synchronize-module-fails/31230/1 "2019-09-09T08:04:28Z")

</div>

I wish to copy all files

from

localhost IP(10.8.33.44) folder location: /app/tmpfiles/

to multiple destination IPs with user id user2 at location /app/IBM/profiles/backup/54166/

I run the playbook from localhost IP(10.8.33.44) with user id user1.

I’m using synchronize module to do this. I use delegate\_to: localhost so that the files from copied from local src only.

Below is my playbook:

`

- name: “Play 3”  
hosts: dest\_nodes  
any\_errors\_fatal: True  
user: user2

- name: “Backup of files on Destination Server {{ inventory\_hostname }}.”  
synchronize:  
src: “{{ playbook\_dir }}/tmpfiles/”  
dest: “{{ vars[inventory\_hostname] }}/{{ Relative\_Path }}/backup/{{ Number }}/”  
mode: push  
delegate\_to: localhost  
`

The issue occurs in copy when the host and destination are the same i.e localhost IP(10.8.33.44)

The playbook run fails due to permission issue because rsync command constructed by ansible is incorrect and is trying to copy files as user1 on destination server instead of user2.

Below is the error log:

> TASK [Backup of files on Destination Server 10.8.33.44.] \*\*\*  
> fatal: [10.8.33.44 → localhost]: FAILED! =\> {“changed”: false, “cmd”: “/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --out-format=\<\>%i %n%L /app/tmpfiles/ [user1@10.8.33.44](mailto:user1@10.8.33.44):/was/IBM/profiles/backup/54166/”, “msg”: “Warning: Permanently added ‘10.8.33.44’ (ECDSA) to the list of known hosts.\r\nrsync: ERROR: cannot stat destination "/was/IBM/profiles/backup/54166/": Permission denied (13)\nrsync error: errors selecting input/output files, dirs (code 3) at main.c(635) [Receiver=3.1.2]\n”, “rc”: 3}

Can you please help me with a solution to this ?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 9, 2019, 10:40am UTC](https://forum.ansible.com/t/copy-files-from-local-to-all-destinations-using-synchronize-module-fails/31230/2 "2019-09-09T10:40:57Z")

</div>

A play has no option user:  
ref [https://docs.ansible.com/ansible/latest/reference\_appendices/playbooks\_keywords.html#play](https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#play)

on a play it's called remote\_user:
