<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.2.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.0.2.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Mac OSX El Capitan (10.11.3)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">This issue is strange. If I use the public DNS provided by AWS, Ansible fails to connect (see error report below). But if I use the IP address it can connect and everything works.</p>
<p dir="auto">Just to make sure, I can ssh into it without issues (providing the same username and key file than ansible is using).</p>
<h3 dir="auto">Output Error</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="No config file found; using defaults
Loaded callback default of type stdout, v2.0

PLAYBOOK: rmotr_admin-deploy.yml ***********************************************
1 plays in playbooks/rmotr_admin-deploy.yml

PLAY [rmotr-admin] *************************************************************

TASK [setup] *******************************************************************
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; ESTABLISH SSH CONNECTION FOR USER: ubuntu
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_PRIVATE_KEY_FILE/private_key_file/ansible_ssh_private_key_file set: (-o)(IdentityFile=&quot;/Users/santiagobasulto/.ssh/rmotr.pem&quot;)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=ubuntu)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: PlayContext set ssh_common_args: ()
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: PlayContext set ssh_extra_args: ()
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile=&quot;/Users/santiagobasulto/.ssh/rmotr.pem&quot;' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r ec2-52-18-118-51.eu-west-1.compute.amazonaws.com '/bin/sh -c '&quot;'&quot;'( umask 22 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `&quot; &amp;&amp; echo &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `&quot; )'&quot;'&quot;''
fatal: [ec2-52-18-118-51.eu-west-1.compute.amazonaws.com]: UNREACHABLE! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Failed to connect to the host via ssh.&quot;, &quot;unreachable&quot;: true}
        to retry, use: --limit @playbooks/rmotr_admin-deploy.retry

PLAY RECAP *********************************************************************
ec2-52-18-118-51.eu-west-1.compute.amazonaws.com : ok=0    changed=0    unreachable=1    failed=0"><pre class="notranslate"><code class="notranslate">No config file found; using defaults
Loaded callback default of type stdout, v2.0

PLAYBOOK: rmotr_admin-deploy.yml ***********************************************
1 plays in playbooks/rmotr_admin-deploy.yml

PLAY [rmotr-admin] *************************************************************

TASK [setup] *******************************************************************
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; ESTABLISH SSH CONNECTION FOR USER: ubuntu
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_PRIVATE_KEY_FILE/private_key_file/ansible_ssh_private_key_file set: (-o)(IdentityFile="/Users/santiagobasulto/.ssh/rmotr.pem")
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=ubuntu)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: PlayContext set ssh_common_args: ()
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: PlayContext set ssh_extra_args: ()
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r)
&lt;ec2-52-18-118-51.eu-west-1.compute.amazonaws.com&gt; SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/santiagobasulto/.ssh/rmotr.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r ec2-52-18-118-51.eu-west-1.compute.amazonaws.com '/bin/sh -c '"'"'( umask 22 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `" &amp;&amp; echo "` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `" )'"'"''
fatal: [ec2-52-18-118-51.eu-west-1.compute.amazonaws.com]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
        to retry, use: --limit @playbooks/rmotr_admin-deploy.retry

PLAY RECAP *********************************************************************
ec2-52-18-118-51.eu-west-1.compute.amazonaws.com : ok=0    changed=0    unreachable=1    failed=0
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<p dir="auto">Feature Idea</p>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ssh control persist</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">2.0</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When trying to use the ec2 plugin, ssh fails with this error:</p>
<p dir="auto"><code class="notranslate">SSH Error: unix_listener: "/Users/luke/.ansible/cp/ansible-ssh-ec2-255-255-255-255.compute-1.amazonaws.com-22-ubuntu.CErvOvRE5U0urCgm" too long for Unix domain socket</code></p>
<p dir="auto">Here's the full example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible -vvvv -i ec2.py -u ubuntu us-east-1 -m ping
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; ESTABLISH CONNECTION FOR USER: ubuntu
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; REMOTE_MODULE ping
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/Users/luke/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 ec2-255-255-255-255.compute-1.amazonaws.com /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180'
ec2-255-255-255-255.compute-1.amazonaws.com | FAILED =&gt; SSH Error: unix_listener: &quot;/Users/luke/.ansible/cp/ansible-ssh-ec2-255-255-255-255.compute-1.amazonaws.com-22-ubuntu.CErvOvRE5U0urCgm&quot; too long for Unix domain socket
    while connecting to 255.255.255.255:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue."><pre class="notranslate"><code class="notranslate">$ ansible -vvvv -i ec2.py -u ubuntu us-east-1 -m ping
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; ESTABLISH CONNECTION FOR USER: ubuntu
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; REMOTE_MODULE ping
&lt;ec2-255-255-255-255.compute-1.amazonaws.com&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/luke/.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 ec2-255-255-255-255.compute-1.amazonaws.com /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1436458336.4-21039895766180'
ec2-255-255-255-255.compute-1.amazonaws.com | FAILED =&gt; SSH Error: unix_listener: "/Users/luke/.ansible/cp/ansible-ssh-ec2-255-255-255-255.compute-1.amazonaws.com-22-ubuntu.CErvOvRE5U0urCgm" too long for Unix domain socket
    while connecting to 255.255.255.255:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
</code></pre></div>
<p dir="auto">I've changed some of the sensitive info in here like the IP etc.</p>