# rysnc ansible

**URL:** <https://forum.ansible.com/t/rysnc-ansible/33545>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [August 4, 2020, 8:31am UTC](https://forum.ansible.com/t/rysnc-ansible/33545 "2020-08-04T08:31:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy.hung](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sandy.hung](https://forum.ansible.com/u/sandy.hung)\
**Post date:** [August 4, 2020, 8:31am UTC](https://forum.ansible.com/t/rysnc-ansible/33545/1 "2020-08-04T08:31:10Z")

</div>

I have synchronize playbook but show error message  
this my playbook

- hosts: localhost  
connection: local  
gather\_facts: no

tasks:

- name: push local folder to remote host  
synchronize:  
src: /tmp/client/  
dest: /tmp/test/  
mode: push  
rsync\_opts: ‘-e “ssh -i /home/ubuntu/.ssh/xxx.pem” unbuntu@xx.xx.xx.xx:/tmp/test/’  
delegate\_to: xxx.xxx.xxxx

run playbook show error message , I have path xxx.pem I can ssh access,can help  
thanks.

TASK [push local folder to remote host] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/ubuntu/aws-efs/sync.yml:7  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/files/synchronize.py  
\<xxx.xxxx\> ESTABLISH SSH CONNECTION FOR USER: None  
\<xxx.xxx\> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/ubuntu/.ansible/cp/1eadf75351 xxx.xx.xx ‘/bin/sh -c ‘"’“‘echo ~ && sleep 0’”’"‘’  
 (255, ‘’, ‘root@xx.xx.x.x: Permission denied (publickey).\r\n’)  
fatal: [localhost]: UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: root@xx.xx.xx.xx: Permission denied (publickey).\r\n”,  
“unreachable”: true  
}  
to retry, use: --limit @/home/ubuntu/aws-efs/sync.retry

---

<div class="post-metadata">

**Author:** ![Luca\_remix\_tj\_Lorenz](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Luca\_remix\_tj\_Lorenz](https://forum.ansible.com/u/Luca_remix_tj_Lorenz)\
**Post date:** [August 4, 2020, 11:38am UTC](https://forum.ansible.com/t/rysnc-ansible/33545/2 "2020-08-04T11:38:00Z")

</div>

Hello,

with delegate to you're telling ansible to connect to xxx.xxx.xxxx and  
run the task. If you want to copy from local to remote, set as hosts:  
the remote host (with authkey and user) and remove delegate\_to. This  
will copy the local /tmp/client to /tmp/test on the remote host.

Luca
