# Synchronize module fails to push data to hosted local VMs

**URL:** <https://forum.ansible.com/t/synchronize-module-fails-to-push-data-to-hosted-local-vms/21854>\
**Category:** Ansible Project\
**Created:** [June 24, 2016, 2:59pm UTC](https://forum.ansible.com/t/synchronize-module-fails-to-push-data-to-hosted-local-vms/21854 "2016-06-24T14:59:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic\_Lionello](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@Frederic\_Lionello](https://forum.ansible.com/u/Frederic_Lionello)\
**Post date:** [June 24, 2016, 2:59pm UTC](https://forum.ansible.com/t/synchronize-module-fails-to-push-data-to-hosted-local-vms/21854/1 "2016-06-24T14:59:26Z")

</div>

Hello,

In my ansible inventory, I have VMs on localhost defined:

myvm ansible\_port=15022 ansible\_host=127.0.0.1 ansible\_user=tibco

I’m trying to synchronize a local directory from the control host (running ansible) to ‘`myvm`’ but this fails since it seems to treat “localhost” differently:

$ ansible -i inventories/inventory.ini -m synchronize -a ‘src=/Users/flionell/Downloads/ojdbc/ dest=/home/tibco/tibco\_home/ojdbclib’ myvm  
myvm | FAILED! =\> {  
“changed”: false,  
“cmd”: “/usr/bin/rsync --delay-updates -F --compress --archive --rsh ‘ssh -S none -o StrictHostKeyChecking=no -o Port=15022’ --out-format=‘\<\>%i %n%L’ "/Users/flionell/Downloads/ojdbc/" "/home/tibco/tibco\_home/ojdbclib"”,  
“failed”: true,  
“msg”: “rsync: mkdir "/home/tibco/tibco\_home/ojdbclib" failed: No such file or directory (2)\nrsync error: error in file IO (code 11) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/main.c(544) [receiver=2.6.9]\nrsync: connection unexpectedly closed (8 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]\n”,  
“rc”: 12  
}

It seems `synchronize` is trying to sync localhost to itself, not using my `ansible_host` or `ansible_user` variables. See the parameters to rsync, the target doesn’t contain “user@host:” prefixes.

If I use a host different from localhost / 127.0.0.1, it sends correct parameters to rsync with user@host:…

> unexisting\_host ansible\_host=some\_host\_name ansible\_user=someuser

> ansible -i inventories/inventory.ini -m synchronize -a ‘src=/Users/flionell/Downloads/ojdbc/ dest=/home/tibco/tibco\_home/ojdbclib’ unexisting\_host
> 
> unexisting\_host | FAILED! =\> {
> 
> “changed”: false,
> 
> “cmd”: “/usr/bin/rsync --delay-updates -F --compress --archive --rsh ‘ssh -S none -o StrictHostKeyChecking=no’ --out-format=‘\<\>%i %n%L’ "/Users/flionell/Downloads/ojdbc/" "someuser@some\_host\_name:/home/tibco/tibco\_home/ojdbclib"”,
> 
> “failed”: true,
> 
> “msg”: “ssh: Could not resolve hostname some\_host\_name: nodename nor servname provided, or not known\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]\n”,
> 
> “rc”: 12
> 
> }

Does that rings a bell to anyone ?

Thanks,  
Regards,

---

<div class="post-metadata">

**Author:** ![Justin\_White](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@Justin\_White](https://forum.ansible.com/u/Justin_White)\
**Post date:** [June 27, 2016, 6:44pm UTC](https://forum.ansible.com/t/synchronize-module-fails-to-push-data-to-hosted-local-vms/21854/2 "2016-06-27T18:44:01Z")

</div>

Just ran into the same issue. Were you able to come up with a fix or work around?

---

<div class="post-metadata">

**Author:** ![Frederic\_Lionello](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@Frederic\_Lionello](https://forum.ansible.com/u/Frederic_Lionello)\
**Post date:** [June 29, 2016, 2:40pm UTC](https://forum.ansible.com/t/synchronize-module-fails-to-push-data-to-hosted-local-vms/21854/3 "2016-06-29T14:40:24Z")

</div>

Yes, I worked around it by:

- defining an alias to 127.0.0.1 in /etc/hosts to “localvm”.
- using this alias in inventory.ini

I guess the module just has special cases for localhost and 127.0.0.1 …

Thanks,  
Regards,
