# Ansible failing to copy module to target host

**URL:** <https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863>\
**Category:** Ansible Project\
**Created:** [March 26, 2014, 12:39pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863 "2014-03-26T12:39:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marko\_Lisica](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Marko\_Lisica](https://forum.ansible.com/u/Marko_Lisica)\
**Post date:** [March 26, 2014, 12:39pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/1 "2014-03-26T12:39:35Z")

</div>

Hi,

I’ve ran to a problem provisioning one host.

I have playbook that successfully provisions vagrant box, but running that on amazon host I get this

> PUT /tmp/tmpxFGcNu TO /tmp/ansible/ansible-tmp-1395837087.32-71225947296118/setup

> [ec2-xx-xx-xx-xx.compute-1.amazonaws.com](http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com) | FAILED =\> failed to transfer file to /tmp/ansible/ansible-tmp-1395837087.32-71225947296118/setup:

> Couldn’t read packet: Connection reset by peer

When I check out tmp dir on remote host I see directiories are created by ansible but no file inside.

Here is complete output:

---

<div class="post-metadata">

**Author:** ![Marko\_Lisica](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Marko\_Lisica](https://forum.ansible.com/u/Marko_Lisica)\
**Post date:** [March 26, 2014, 1:45pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/2 "2014-03-26T13:45:11Z")

</div>

Let me add few more thins and answer to my question.

I have run this on three machines.

Ubuntu 13.04 - Ansible 1.5.3 error was:

> PUT /tmp/tmpxFGcNu TO /tmp/ansible/ansible-tmp-1395837087.32-71225947296118/setup

> [ec2-xx-xx-xx-xx.compute-1.amazonaws.com](http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com) | FAILED =\> failed to transfer file to /tmp/ansible/ansible-tmp-

> 1395837087.32-71225947296118/setup:

> 

> Couldn’t read packet: Connection reset by peer

Mac OSX - Ansible 1.4.4:

> ```auto
> > FAILED => failed to transfer file to /home/admin/.ansible/tmp/ansible-1395838813.75-19289519445016/setup:
> 
> ControlPath "/Users/marko/.ansible/cp/ansible-ssh-ec2-54-236-227-155.compute-1.amazonaws.com-22-admin.MEUoiLFZkgoecYzU" too long for Unix domain socket
> subsystem request failed on channel 0
> Connection closed
> 
> ```

And Debian 7.1 - Ansible 1.6:

> failed to open a SFTP connection (Channel closed.)

I have enable scp\_if\_ssh = True  
and all went well.

Is it only version issue woth dofferent error messages?

---

<div class="post-metadata">

**Author:** ![Zaven](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@Zaven](https://forum.ansible.com/u/Zaven)\
**Post date:** [June 11, 2014, 8:10pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/3 "2014-06-11T20:10:55Z")

</div>

We have been experiencing this bug consistently for some time. Is there a ticket to track this, Ansiblers?

fatal: [[ec2-54-xxx-yyy-zz.us-west-2.compute.amazonaws.com](http://ec2-54-xxx-yyy-zz.us-west-2.compute.amazonaws.com)] =\> failed to transfer file to /home/ubuntu/.ansible/tmp/ansible-tmp-1402514262.96-23740295147290/source:

Warning: Permanently added ‘[ec2-54-xxx-yyy-zz.us-west-2.compute.amazonaws.com](http://ec2-54-xxx-yyy-zz.us-west-2.compute.amazonaws.com),54.xxx.yyy.zz’ (RSA) to the list of known hosts.  
ControlPath “/Users/zaven/.ansible/cp/ansible-ssh-ec2-54-xxx-yyy-xx.us-west-2.compute.amazonaws.com-22-ubuntu.pIvKZuLKKh2LEqwd” too long for Unix domain socket  
Write failed: Broken pipe  
Connection closed

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 12, 2014, 12:00am UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/4 "2014-06-12T00:00:59Z")

</div>

It’s not a bug so much as a setting you need to change in ansible.cfg because there’s very little we can do about it.

See: [http://docs.ansible.com/intro\_configuration.html#control-path](http://docs.ansible.com/intro_configuration.html#control-path)

---

<div class="post-metadata">

**Author:** ![John\_Ross\_Tasipit](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@John\_Ross\_Tasipit](https://forum.ansible.com/u/John_Ross_Tasipit)\
**Post date:** [August 27, 2014, 6:02am UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/5 "2014-08-27T06:02:59Z")

</div>

It could be the sftp config line on the host’s /etc/ssh/sshd\_config:

Subsystem sftp /usr/libexec/openssh/sftp-server #the path may be different depends on your OS

---

<div class="post-metadata">

**Author:** ![A\_Potek](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@A\_Potek](https://forum.ansible.com/u/A_Potek)\
**Post date:** [January 15, 2015, 9:37pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/6 "2015-01-15T21:37:08Z")

</div>

This problem can exist even in cases where the control-path is reconfigured to be shorter. I made that change in my configuration and it did nothing to resolve the issue.

`  
\<##.#.#.#\> ESTABLISH CONNECTION FOR USER: [username]  
\<##.#.#.#\> REMOTE\_MODULE setup  
\<##.#.#.#\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/[username]/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘##.#.#.#’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1421357644.16-197958593810564 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1421357644.16-197958593810564 && echo $HOME/.ansible/tmp/ansible-tmp-1421357644.16-197958593810564’”]  
\<##.#.#.#\> PUT /tmp/tmpXLEUtz TO /home/[username]/.ansible/tmp/ansible-tmp-1421357644.16-197958593810564/setup

fatal: [##.#.#.#] =\> failed to transfer file to /home/USER/.ansible/tmp/ansible-tmp-1421357538.57-18056896264178/setup:

Received message too long 1919246692

`

As you can see, the number of characters is actually nowhere near the amount needed to trigger that error on my systems, and yet, that’s the error that is reported back.

I think something else is actually going on behind the scenes and the error reported back by ansible is making an assumption about the cause of the failure.

In addition, my /etc/ssh/sshd\_config is correct for my OS and the path to sftp-server is correct.

---

<div class="post-metadata">

**Author:** ![A\_Potek](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@A\_Potek](https://forum.ansible.com/u/A_Potek)\
**Post date:** [January 16, 2015, 5:02pm UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/7 "2015-01-16T17:02:33Z")

</div>

Pls ignore. My issue is unrelated and seems to be caused by an “unclean” ssh connection where a .bashrc resource or something similar is echoing something back during the login and causing the content length to be corrupted.

---

<div class="post-metadata">

**Author:** ![Shaun\_Barker](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@Shaun\_Barker](https://forum.ansible.com/u/Shaun_Barker)\
**Post date:** [March 4, 2016, 10:59am UTC](https://forum.ansible.com/t/ansible-failing-to-copy-module-to-target-host/14863/8 "2016-03-04T10:59:05Z")

</div>

The only thing that worked for me was from something I found on Stackoverflow:

My version of it here:

sudo pip install ansible //dont need this if you have it installed of course - I didnt as was using my git clone.  
cd /etc/paths.d/  
sudo touch ControlPath  
sudo echo export ANSIBLE\_SSH\_CONTROL\_PATH=‘%(directory)s/%%h-%%r’ \>\> ControlPath  
source ControlPath
