Monday, February 2, 2015

Ansible error ControlPath too long when working with AWS EC2

I have been leaning Ansible for setup and deployment and I am loving it. I did my testing on a local VirtualBox VM so that I could easily revert it back to a clean state. Unfortunately when I went to try my playbooks on an EC2 instance I immediately got an error "ControlPath too long". Adding the generally hlelpfull -vvvv did not help. Even the basic ping failed, but I could ssh into the box fine.

After some hints from the stackoverflow and the Ansible docs I figured it out.

The problem is that the hostname for an ec2 instance is so long that makes the socket name too long to use. You can change the ansible config to use a shorter format, but this was not enough. The easiest solution was to use the IP address in the hosts file instead of the public DNS name.

Other solutions could include changing your /etc/hosts file, or to add a CNAME in DNS.

If you work with EC2 instances I do recommend to change your /etc/ansible/ansible.cfg by uncommenting the line below. This may help in some situations.

 control_path = %(directory)s/%%h-%%r  

This also may become a non-issue when I start using the EC2 tools for Ansible.

No comments:

Post a Comment