Repository: ansible/ansible

Issue:
eos connection issues
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
eos_*

##### ANSIBLE VERSION
```

```


##### SUMMARY
Every second `ansible-playbook` run seems to fail

Doesn't appear to have a bug to track this yet. privateip has seen it locally as well.


##### STEPS TO REPRODUCE
```yaml

```

##### EXPECTED RESULTS

##### ACTUAL RESULTS
```
rm -rf socket
Ensure no ansible-connection process is running
Ensure no SSH keys are available
time ANISBLE_DEBUG=True ANSIBLE_ROLES_PATH=targets  ansible-playbook -vvvvv  -i  inventory.network eos.yaml  -e "limit_to=eos_system"
fails at first network task `test/integration/targets/prepare_eos_tests/tasks/main.yml:1`

****************************************************************************************************************************************************
2017-03-03 12:11:13,075 p=29878 u=johnb |  task path: /home/johnb/git/ansible-inc/ansible-workspace-2/test/integration/targets/prepare_eos_tests/tasks/main.yml:1
<veos01> starting new persistent socket with path /home/johnb/.ansible/pc/ca5960d27a
<veos01> using connection plugin network_cli
<veos01> ESTABLISH CONNECTION FOR USER: admin on PORT 22 TO veos01
2017-03-03 12:11:23,527 p=29878 u=johnb |  fatal: [veos01]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "msg": "unable to open shell"
}
2017-03-03 12:11:23,529 p=29878 u=johnb |       to retry, use: --limit @/home/johnb/git/ansible-inc/ansible-workspace-2/test/integration/eos.retry

2017-03-03 12:11:23,529 p=29878 u=johnb |  PLAY RECAP ***************************************************************************************************************************************************************************************************************************************
2017-03-03 12:11:23,529 p=29878 u=johnb |  veos01                     : ok=0    changed=0    unreachable=0    failed=1   
<veos01> ssh connection done, setting terminal
<veos01> ssh connection has completed successfully
<veos01> closing shell due to sigalarm
<veos01> closing shell on device
<veos01> shutting down control socket, connection was active for 0:00:52.848337 secs
<veos01> closing connection
<veos01> closing shell on device
```



```
running the same command again gives
2017-03-03 12:16:05,500 p=30621 u=johnb |  TASK [prepare_eos_tests : enable cli on remote device] *******************************************************************************************************************************************************************************************
2017-03-03 12:16:05,500 p=30621 u=johnb |  task path: /home/johnb/git/ansible-inc/ansible-workspace-2/test/integration/targets/prepare_eos_tests/tasks/main.yml:1
<veos01> starting new persistent socket with path /home/johnb/.ansible/pc/ca5960d27a
<veos01> using connection plugin network_cli
<veos01> ESTABLISH CONNECTION FOR USER: admin on PORT 22 TO veos01
<veos01> ssh connection done, setting terminal
<veos01> ssh connection has completed successfully
<veos01> incoming request accepted on persistent socket
<veos01> received data on socket with len 1550
<veos01> socket operation is CONTEXT
<veos01> updating play_context for connection
<veos01> received data on socket with len 18
<veos01> socket operation is EXEC
<veos01> attempting to open shell to device
<veos01> shell successfully opened
<veos01> socket operation completed with rc 0
2017-03-03 12:16:11,054 p=30621 u=johnb |  Using module file /home/johnb/git/ansible-inc/ansible-workspace-2/lib/ansible/modules/network/eos/eos_eapi.py
<veos01> incoming request accepted on persistent socket
<veos01> received data on socket with len 79
<veos01> socket operation is EXEC
<veos01> socket operation completed with rc 0
<veos01> incoming request accepted on persistent socket
<veos01> received data on socket with len 111
<veos01> socket operation is EXEC
<veos01> socket operation completed with rc 0
<veos01> incoming request accepted on persistent socket
<veos01> received data on socket with len 111
<veos01> socket operation is EXEC
<veos01> socket operation completed with rc 0
2017-03-03 12:16:12,123 p=30621 u=johnb |  ok: [veos01] => {
```



Discussion:

Resolving patch:
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -347,7 +347,7 @@ def load_config_file():
 PARAMIKO_PROXY_COMMAND         = get_config(p, 'paramiko_connection', 'proxy_command', 'ANSIBLE_PARAMIKO_PROXY_COMMAND', None)
 PARAMIKO_LOOK_FOR_KEYS         = get_config(p, 'paramiko_connection', 'look_for_keys', 'ANSIBLE_PARAMIKO_LOOK_FOR_KEYS', True, value_type='boolean')
 PERSISTENT_CONNECT_TIMEOUT     = get_config(p, 'persistent_connection', 'connect_timeout', 'ANSIBLE_PERSISTENT_CONNECT_TIMEOUT', 30, value_type='integer')
-PERSISTENT_CONNECT_RETRIES     = get_config(p, 'persistent_connection', 'connect_retries', 'ANSIBLE_PERSISTENT_CONNECT_RETRIES', 10, value_type='integer')
+PERSISTENT_CONNECT_RETRIES     = get_config(p, 'persistent_connection', 'connect_retries', 'ANSIBLE_PERSISTENT_CONNECT_RETRIES', 30, value_type='integer')
 PERSISTENT_CONNECT_INTERVAL    = get_config(p, 'persistent_connection', 'connect_interval', 'ANSIBLE_PERSISTENT_CONNECT_INTERVAL', 1, value_type='integer')
 
 # obsolete -- will be formally removed


Test patch: