# Ansible playbook fails on ssh in between the tasks.

**URL:** <https://forum.ansible.com/t/ansible-playbook-fails-on-ssh-in-between-the-tasks/19892>\
**Category:** Ansible Developer\
**Created:** [November 30, 2015, 7:57am UTC](https://forum.ansible.com/t/ansible-playbook-fails-on-ssh-in-between-the-tasks/19892 "2015-11-30T07:57:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vani\_Paridhyani](https://avatars.discourse-cdn.com/v4/letter/v/e0b2c6/32.png) [@Vani\_Paridhyani](https://forum.ansible.com/u/Vani_Paridhyani)\
**Post date:** [November 30, 2015, 7:57am UTC](https://forum.ansible.com/t/ansible-playbook-fails-on-ssh-in-between-the-tasks/19892/1 "2015-11-30T07:57:53Z")

</div>

Hi!

After 5 out of 11 ansible tasks ran successfuly, my playbook failed throwing the below error:

```auto
failed: [<ip>] => {"changed": true, "rc": 1}
stderr: OpenSSH_6.2p2, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /var/lib/jenkins/.ssh/config
debug1: /var/lib/jenkins/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 20175
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
Shared connection to <ip> closed.

```

I want to know the reason of failure and I am wondering how can ssh fail all of a sudden when it worked for the previous tasks.

Thank You!

---

<div class="post-metadata">

**Author:** ![marc.petrivelli](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc.petrivelli/32/3773_2.png) [@marc.petrivelli](https://forum.ansible.com/u/marc.petrivelli)\
**Post date:** [November 30, 2015, 4:55pm UTC](https://forum.ansible.com/t/ansible-playbook-fails-on-ssh-in-between-the-tasks/19892/2 "2015-11-30T16:55:15Z")

</div>

I had this problem and I did two things to ensure it wouldn’t happen:

1. Increase ControlPersist timeout value. check your ssh\_args settings in ansible.cfg. You might need to bump up your ControlPersist timeout. I set mine to 10m

2. Update your ssh config to decrease ServerAliveInterval (in my case to 30) and increase ServerAliveCountMax (in my case to 4). I added these to appropriate user’s .ssh/ssh\_config

---

<div class="post-metadata">

**Author:** ![Bhotu](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@Bhotu](https://forum.ansible.com/u/Bhotu)\
**Post date:** [December 4, 2015, 6:31pm UTC](https://forum.ansible.com/t/ansible-playbook-fails-on-ssh-in-between-the-tasks/19892/3 "2015-12-04T18:31:05Z")

</div>

Why are we decreasing the ServerAliveInterval ?
