# Couldn't read packet: Connection reset by peer

**URL:** <https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198>\
**Category:** Ansible Project\
**Created:** [July 25, 2013, 8:06pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198 "2013-07-25T20:06:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 25, 2013, 8:06pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/1 "2013-07-25T20:06:43Z")

</div>

I’m getting the same type of error trying to run the [openstack playbook](https://github.com/ansible/ansible-redhat-openstack) from a mac 10.8 to a company network server running centOS 6.4.

I installed sshpass on both the openstackserver and my mac.  
I have ssh-keygen 'd on my mac as kbroughton and then  
mac$ ssh-copy-id root@openstackserver

verifying  
openstackserver$ cat /root/.ssh/authorized\_keys  
i see the public key for my kbroughton

```auto

mac$ ssh-agent bash
mac$ ssh-add ~/.ssh/authorized_keys
mac$ ansible-playbook -i hosts site.yml

```

fatal: [10.0.9.170] =\> failed to transfer file to /setup:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).  
Connection closed

I can do passwordless ssh to root@openstackserver. Trying to skirt the ssh-agent:

```auto
ansible-playbook -i hosts site.yml --ask-pass
ansible-playbook -vvv --ask-pass -i hosts site.yml -c ssh 

```

\<10.0.9.172\> REMOTE\_MODULE setup  
\<10.0.9.170\> REMOTE\_MODULE setup  
\<10.0.9.172\> PUT /var/folders/t2/h22337c12hn279xwd4s9fk7s8\_088c/T/tmpEKNksK TO /setup  
\<10.0.9.170\> PUT /var/folders/t2/h22337c12hn279xwd4s9fk7s8\_088c/T/tmpz2Vb82 TO /setup

fatal: [10.0.9.170] =\> failed to transfer file to /setup:

Permission denied, please try again.

suggestions?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [July 26, 2013, 1:46pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/2 "2013-07-26T13:46:04Z")

</div>

try setting ANSIBLE\_REMOTE\_TEMP=/tmp in your shell before running ansible

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 26, 2013, 1:49pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/3 "2013-07-26T13:49:43Z")

</div>

Actually, don’t do that just yet 🙂

Can you test this from a Ansible 1.3 checkout and share your output? Error handling around this is much better there.

It does sound like the “root” account might not have a homedir, but I’d like to see more.

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 26, 2013, 3:25pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/4 "2013-07-26T15:25:32Z")

</div>

Installed 1.3, and yes, the output is much more descriptive:

fatal: [10.0.9.170] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952 && chmod a+rx $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952 && echo $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952) exited with result 255  
fatal: [10.0.9.172] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374851276.99-84075906491343 && chmod a+rx $HOME/.ansible/tmp/ansible-1374851276.99-84075906491343 && echo $HOME/.ansible/tmp/ansible-1374851276.99-84075906491343) exited with result 255

kbroughton:ansible-redhat-openstack$ ssh [root@10.0.9.172](mailto:root@10.0.9.172)

[root@Linux-OpenStack-Compute1 ~]# ls -ld /home  
drwxr-xr-x. 3 root root 4096 Jul 24 08:35 /home  
[root@Linux-OpenStack-Compute1 ~]# lsattr -d /home  
--------------- /home  
[root@Linux-OpenStack-Compute1 ~]# echo $HOME  
/root

$HOME is set on the remotes. If I ssh over and execute  
mkdir -p $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952 && chmod a+rx $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952 && echo $HOME/.ansible/tmp/ansible-1374851276.98-60564789413952

it succeeds. So i’m guessing some kind of expansion error, but not sure what.

kesten

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 26, 2013, 8:34pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/5 "2013-07-26T20:34:35Z")

</div>

So above the -v -v -v output is only partial, can you please share all of and also the command line you used to launch ansible playbook?

Thanks!

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 26, 2013, 11:07pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/6 "2013-07-26T23:07:02Z")

</div>

here it is:

kbroughton:ansible-redhat-openstack$ ansible-playbook -vvv -i hosts site.yml

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<10.0.9.170\> ESTABLISH CONNECTION FOR USER: kbroughton  
\<10.0.9.170\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘10.0.9.170’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971 && chmod a+rx $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971 && echo $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971’”]  
\<10.0.9.172\> ESTABLISH CONNECTION FOR USER: kbroughton  
\<10.0.9.172\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘10.0.9.172’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874 && chmod a+rx $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874 && echo $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874’”]  
fatal: [10.0.9.170] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971 && chmod a+rx $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971 && echo $HOME/.ansible/tmp/ansible-1374852361.71-97030287007971) exited with result 255  
fatal: [10.0.9.172] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874 && chmod a+rx $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874 && echo $HOME/.ansible/tmp/ansible-1374852361.71-43824623726874) exited with result 255

TASK: [copy yum repo files] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/var/tmp/ansible/site.retry

10.0.9.170 : ok=0 changed=0 unreachable=1 failed=0  
10.0.9.172 : ok=0 changed=0 unreachable=1 failed=0

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 27, 2013, 2:55am UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/7 "2013-07-27T02:55:07Z")

</div>

Ok so it’s logging in remotely as kbroughton, not root, since you didn’t specify -u root and were running as you (which is what it should do, in fact…).

Now, your test on the above via SSH login was as root:

[root@Linux-OpenStack-Compute1 ~]# ls -ld /home  
drwxr-xr-x. 3 root root 4096 Jul 24 08:35 /home  
[root@Linux-OpenStack-Compute1 ~]# lsattr -d /home  
--------------- /home  
[root@Linux-OpenStack-Compute1 ~]# echo $HOME  
/root

What happens as you?

In the worst case, yes, you can force the remote temp path to always use /tmp as Brian said, but I suspect that’s the problem.

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 27, 2013, 1:16pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/8 "2013-07-27T13:16:47Z")

</div>

Was I mistaken to think that if a playbook lists

user: root

then that playbook would try to connect via ssh as root to the remote host? I also tried the various --ask-pass-sudo which I thought, again, would try and run AND connect as root (by defualt). I don’t currently have a kbroughton account set up on the remote. I will try that and then brian’s suggestion next.

Here is the output when i pass the -u root to commanline:

623 kbroughton:ansible-redhat-openstack$ ansible-playbook -u root -vvv -i hosts site.yml

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<10.0.9.172\> ESTABLISH CONNECTION FOR USER: root  
\<10.0.9.170\> ESTABLISH CONNECTION FOR USER: root  
\<10.0.9.170\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=root’, ‘-o’, ‘ConnectTimeout=10’, ‘10.0.9.170’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1374930395.38-278372863854939 && echo $HOME/.ansible/tmp/ansible-1374930395.38-278372863854939’”]  
\<10.0.9.172\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=root’, ‘-o’, ‘ConnectTimeout=10’, ‘10.0.9.172’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1374930395.38-95551726821490 && echo $HOME/.ansible/tmp/ansible-1374930395.38-95551726821490’”]  
fatal: [10.0.9.172] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374930395.38-95551726821490 && echo $HOME/.ansible/tmp/ansible-1374930395.38-95551726821490) exited with result 255  
fatal: [10.0.9.170] =\> could not create temporary directory, SSH (mkdir -p $HOME/.ansible/tmp/ansible-1374930395.38-278372863854939 && echo $HOME/.ansible/tmp/ansible-1374930395.38-278372863854939) exited with result 255

TASK: [copy yum repo files] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 28, 2013, 9:22pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/9 "2013-07-28T21:22:32Z")

</div>

user: root in the playbook will indeed make it use root, if you are NOT seeing that, I’d like to see the playbook as you probably have it in some weird spot 🙂

I’m a little confused as to what’s up with root’s homedir there.

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 29, 2013, 3:03am UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/10 "2013-07-29T03:03:41Z")

</div>

The playbook is a very minally modified version of the openstack playbook recently posted

[https://github.com/ansible/ansible-redhat-openstack/issues/6#issuecomment-21384265](https://github.com/ansible/ansible-redhat-openstack/issues/6#issuecomment-21384265)

The playbook’s author, Benno Joy, had told me,  
“The playbook has user root set in it and sudo in enabled in the playbook, so you would have to tweak the playboo a bit to make sudo work.”

So i presumed user: root was set somewhere.  
I didn’t see it when I went to double check, so i added it to the three host targets in site.yml.

This didn’t change the errors i received previously. Other than that, the only change i made was to rename the hosts and put in my ip address. I’ve tried the playbook on both a single basic centOS 6.4 instance at rackspace, and a two-node version hosted by company servers (again centOS 6.4).

Here is the root-level diff of the project:

679 kbroughton:ansible-redhat-openstack$ git diff  
diff --git a/hosts b/hosts  
index a20e1fc..360856d 100644  
— a/hosts  
+++ b/hosts  
@@ -1,7 +1,9 @@  
-[openstack\_controller]  
-openstack-controller  
+[local\_openstack\_controller]  
+166.78.180.192  
+#openstack-controller

-[openstack\_compute]  
-openstack-compute  
+[local\_openstack\_compute]  
+166.78.180.192  
+#openstack-compute

diff --git a/site.yml b/site.yml  
index 246ac96..0702298 100644  
— a/site.yml  
+++ b/site.yml  
@@ -2,14 +2,17 @@

# The main openstack site deployment playbook

- hosts: all

- user: root  
roles:

- common

- hosts: openstack\_controller

- user: root  
roles:

- controller

- hosts: openstack\_compute

- user: root  
roles:

- compute

I’m still getting:

$ kbroughton:ansible-redhat-openstack$ ansible-playbook -i hosts site.yml

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [166.78.180.192] =\> could not create temporary directory, SSH (mkdir -p /tmp/ansible-1375066315.04-89253282885227 && echo /tmp/ansible-1375066315.04-89253282885227) exited with result 255

TASK: [copy yum repo files] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/var/tmp/ansible/site.retry

166.78.180.192 : ok=0 changed=0 unreachable=1 failed=0

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [July 29, 2013, 3:19pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/11 "2013-07-29T15:19:07Z")

</div>

Hi Kesten,

The reason the task at 25 is failing is because it expects the hostname in inventory, so couple of options are

in your inventory add somthing like

[openstack-controller]  
huebertus ansible\_ssh\_host=166.78.180.192  
[openstack-compute]

huebertus ansible\_ssh\_host=166.78.180.192

or another option in the template

CONTROLLER\_PUBLIC\_ADDRESS={{ hostvars[ansible\_hostname][‘ansible\_’+iface].ipv4.address }}

CONTROLLER\_ADMIN\_ADDRESS={{ hostvars[ansible\_hostname][‘ansible\_’+iface].ipv4.address }}

CONTROLLER\_INTERNAL\_ADDRESS={{ hostvars[ansible\_hostname][‘ansible\_’+iface].ipv4.address }}

replace anible\_hostname with inventory\_hostname

As for the problem of not able to copy files into temp directory, can you try disabling selinux manually and see if it helps.

Thanks,  
Benno

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [July 29, 2013, 10:33pm UTC](https://forum.ansible.com/t/couldnt-read-packet-connection-reset-by-peer/13198/12 "2013-07-29T22:33:40Z")

</div>

Thanks benno.  
SOLVED and SOLVED

I chose solution 1 for the hostname issue.
