我正在尝试将Ansible与几个CoreOS虚拟机一起使用。我安装了ActivePython,系统识别二进制文件。当我尝试使用内置的Ansible模块(ping)进行测试时,会抛出以下错误:
deploy@kube-bh:~$ ansible dhcp-coreos155 -m ping
dhcp-coreos155 | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Shared connection to dhcp-coreos155 closed.\r\n",
"module_stdout": "/bin/sh: -c: line 0: unexpected EOF while looking for matching `\"'\r\n/bin/sh: -c: line 1: syntax error: unexpected end of file\r\n",
"msg": "MODULE FAILURE",
"rc": 1
}
有趣的是,如果我使用-m raw
运行Ansible命令,则会成功:
deploy@kube-bh:~$ ansible dhcp-coreos155 -m raw -a 'uptime'
dhcp-coreos155 | SUCCESS | rc=0 >>
20:02:21 up 1 day, 22:11, 2 users, load average: 0.00, 0.00, 0.00
Shared connection to dhcp-coreos155 closed.
我在失败命令上使用-vvvv
标志来查看连接状态,看来SSH正在正确连接到CoreOS节点。我收集了更多信息,但为什么错误发生并不清楚。
<dhcp-coreos155> ESTABLISH SSH CONNECTION FOR USER: deploy
<dhcp-coreos155> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/home/deploy/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=deploy -o ConnectTimeout=10 -o ControlPath=/home/deploy/.ansible/cp/6852b73873 -tt dhcp-coreos155 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-fisdfsesqopuqybnmnfhfdijsvkmxvoh; /home/deploy/bin/python" /home/deploy/.ansible/tmp/ansible-tmp-1510602904.61-255211842882017/ping.py; rm -rf "/home/deploy/.ansible/tmp/ansible-tmp-1510602904.61-255211842882017/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<dhcp-coreos155> (1, '/bin/sh: -c: line 0: unexpected EOF while looking for matching `"\'\r\n/bin/sh: -c: line 1: syntax error: unexpected end of file\r\n', 'Shared connection to dhcp-coreos155 closed.\r\n')
答案 0 :(得分:0)
对我来说,看起来你已经在某处弄乱了Python可执行文件定义(你不显示配置,它可能是Ansible清单或ansible.cfg
) - 存在不平衡的报价命令Ansible中的标记执行:
/home/deploy/bin/python"
Shell打开一个引号,但在找到匹配的右引号之前,整个命令结束,因此它会抛出一个意外的EOF找到的异常。
raw
模块没有调用Python,因此没有错误。