问题原文
原帖链接 · darksideofthesun · CC BY-SA 3.0
I'm trying to run a simple Ansible playbook against an already-provisioned EC2 host. When I run ansible-playbook, I get the following error:
SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh
Using the Amazon-supplied .pem file, I can manually ssh into the box just fine by just doing
ssh ubuntu@my_instance_ip
.
This is the full command I'm running:
ansible-playbook --inventory-file=inventory/production --extra-vars=ansible_ssh_user=ubuntu my-playbook.yml -vvvv
This is my inventory file (IP/DNS masked):
[test]
ec2-1-1-1-1.us-west-1.compute.amazonaws.com ansible_ssh_private_key_file=~/path_to_pem_file.pem
The interesting thing is if I run the ssh command that the ansible-playbook verbosely spits out:
ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60m -o ControlPath="/Users/me/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/path_to_my_pem_file.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 ec2-1-1-1-1.us-west-1.compute.amazonaws.com
I get the following:
debug3: muxserver_listen: temporary control path /Users/me/.ansible/cp/ansible-ssh-ec2-1-1-1-1.us-west-1.compute.amazonaws.com-22-ubuntu.8MjEBnDdRIAO8zAT
unix_listener: "/Users/me/.ansible/cp/ansible-ssh-ec2-1-1-1-1.us-west-1.compute.amazonaws.com-22-ubuntu.8MjEBnDdRIAO8zAT" too long for Unix domain socket
Is that error valid? If so, is there anyway to make the command shorter? Thanks!
已采纳解答
原帖链接 · Henrik Pingel · CC BY-SA 3.0
As already pointed out in the comments and in the linked SO question the relevant error message here is: too long for Unix domain socket. This error can be solved by tweaking the control_path parameter in ansible.cfg
The path to use for the ControlPath sockets. This defaults to "%(directory)s/ansible-ssh-%%h-%%p-%%r", however on some systems with very long hostnames or very long path names (caused by long user names or deeply nested home directories) this can exceed the character limit on file socket names (108 characters for most platforms). In that case, you may wish to shorten the string below.
Example: control_path = %(directory)s/%%h-%%r
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
