solution for ” too long for Unix domain socket ” with ansible and amazon ec2

fatal: [ec2-x.x.x.x.us-west-2.compute.amazonaws.com] => SSH Error: unix_listener: "/home/shrinivasan/.ansible/cp/ansible-ssh-x.x.x.x.us-west-2.compute.amazonaws.com-22-ubuntu.0wqQt0HttbVPpz9B" too long for Unix domain socket
while connecting to x.x.x.x:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

I got the above error on ansible, when used huge hostnames ( amazon ec2 names) instead of IP addresses, in hosts file for ansible.

Ansible can not log in the the machines via ssh.

To solve this, in /etc/ansible/ansible.cfg file, enable the following.
control_path = %(directory)s/%%h-%%r

After this, ansible can login to remote servers and run the scripts.

2 thoughts on “solution for ” too long for Unix domain socket ” with ansible and amazon ec2

  1. I was scratching my head for 2-3 hours, ansible 2.0.2.0 didnt give any debug info for ping module even after providing -vvvv option.
    Downgraded ansible to 2.0.1.0 and then I got the proper debug message. Your solution worked like charm!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s