大网数据广告活动
服务器运维问答

Can't run Ansible playbook against EC2 host

· 52CE 我爱测

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…

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。