-1

尝试运行命令“ansible -m ping uat”时出现错误,但我可以通过跳转服务器从主机 ssh 到远程服务器。

我用 Mitogen 来加速。请查看使用 -vvv 运行 ansible ping 命令时获取的以下日志。

以下是日志:

ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/var/lib/buildkite-agent/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Apr 15 2020, 17:07:12) [GCC 5.4.0 20160609]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[top  2214] 09:24:54.188656 D ansible_mitogen.affinity: CPU mask for Ansible top-level process: 0x000001
[top  2214] 09:24:54.189123 D ansible_mitogen.process: inherited open file limits: soft=1024 hard=1048576
[top  2214] 09:24:54.189331 D ansible_mitogen.process: raised soft open file limit from 1024 to 1048576
[mux  2220] 09:24:54.191415 D ansible_mitogen.affinity: CPU mask for MuxProcess 0: 0x000001
[mux  2220] 09:24:54.198012 D mitogen.service: Pool(b090, size=32, th='MainThread'): initialized
[mux  2220] 09:24:54.198853 D ansible_mitogen.process: Service pool configured: size=32
META: ran handlers
[task 2254] 09:24:54.251656 D ansible_mitogen.affinity: CPU mask for WorkerProcess: 0x000001
[task 2254] 09:24:54.277281 D ansible_mitogen.process: will use multiplexer 0 (/tmp/mitogen_unix_TcnPxD.sock) to connect to "uat"
[task 2254] 09:24:54.277627 D mitogen.unix: client: connecting to /tmp/mitogen_unix_TcnPxD.sock
[mux  2220] 09:24:54.278489 D mitogen.unix: listener: accepted connection from PID 2254: unix_client.2254
[task 2254] 09:24:54.278822 D mitogen.unix: client: local ID is 1, remote is 0
[mux  2220] 09:24:54.281714 D mitogen.parent: creating connection to context 2 using mitogen.ssh
[mux  2220] 09:24:54.414368 D mitogen.parent: command line for Connection(None): ssh -o "LogLevel ERROR" -o "Compression yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 10" -o "BatchMode yes" -o "StrictHostKeyChecking yes" -C -o ControlMaster=auto -o ControlPersist=60s -o "ProxyCommand=ssh -W %h:%p -q 34.104.54.8" 54.64.243.180 /usr/bin/python -c "'import codecs,os,sys;_=codecs.decode;exec(_(_(\"eNqFkcFLwzAUxs/rX9HbSzDd0o4hFALKDuJBhCLuoEPaJdWwLglpuzr/et86ce08CDm8H9/38j3ey9hK2HrqtFOEBp51A9JliFBavyU0DSZYy9YlhLOYc3rmjA3JoxqfeFPZWpFsCH4IqyF0CBhYHzC+yhtM3YVChCBz32kDYW5kL6pPtWmbvKhUL8/a2s8KbWbu0HxYAzjn5MJ2JfrGvfK1tuYlna/7WGX22iPDbXb3zGEtxm0nD2JFxgIb4xWQnW7suzJp0epKbnWjohyxudEuinnEozm+RZokCadAA/y282giMYOH+6dHzvmrARxnYyVunQZL8UaOe5fWKYPbBl8AnXqVSxJf82RBGXxphz+VTpx9KwZdAcdTlO4nYNnXp/VeuLv/3H+njMdT/h4uod9dUrTr\".encode(),\"base64\"),\"zip\"))'"
[mux  2220] 09:24:54.419761 D mitogen.parent: child for Connection(None) started: pid:2258 stdin:77 stdout:77 stderr:79
[mux  2220] 09:24:54.526474 D mitogen.parent: ssh.54.64.243.180: (unrecognized): ssh_exchange_identification: Connection closed by remote host
[mux  2220] 09:24:54.526830 D mitogen: <Side of ssh.54.64.243.180 fd 77>: empty read, disconnecting
[mux  2220] 09:24:54.527372 D mitogen: BootstrapProtocol(ssh.54.64.243.180): disconnecting
[mux  2220] 09:24:54.527801 D mitogen: <Side of ssh.54.64.243.180 fd 79>: empty read, disconnecting
[mux  2220] 09:24:54.528086 D mitogen.parent: failing connection ssh.54.64.243.180 due to EofError(u'EOF on stream; last 100 lines received:\nssh_exchange_identification: Connection closed by remote host\r',)
[mux  2220] 09:24:54.528393 D mitogen.parent: PopenProcess ssh.54.64.243.180 pid 2258: exited with return code 255
[mux  2220] 09:24:54.528581 D mitogen: SetupProtocol(ssh.54.64.243.180): disconnecting
[mux  2220] 09:24:54.529214 D mitogen: SetupProtocol(ssh.54.64.243.180): disconnecting
[task 2254] 09:24:54.529820 D ansible_mitogen.mixins: _remove_tmp_path(None)
[task 2254] 09:24:54.530132 D mitogen: MitogenProtocol(unix_listener.2220): disconnecting
[task 2254] 09:24:54.530568 D mitogen: Waker(fd=11/12): disconnecting
[task 2254] 09:24:54.530990 D mitogen: Router(Broker(b290)): stats: 0 module requests in 0 ms, 0 sent (0 ms minify time), 0 negative responses. Sent 0.0 kb total, 0.0 kb avg.
[mux  2220] 09:24:54.531810 D mitogen: <Side of unix_client.2254 fd 76>: empty read, disconnecting
[mux  2220] 09:24:54.532045 D mitogen: MitogenProtocol(unix_client.2254): disconnecting

错误信息:

*uat | UNREACHABLE! => {
    "changed": false, 
    "msg": "EOF on stream; last 100 lines received:\nssh_exchange_identification: Connection closed by remote host\r", 
    "unreachable": true
}*
4

2 回答 2

0

这是一个不寻常的问题。如果您已建立成功的 SSH 连接,则不应发生这种情况。确保所有主机都添加到您尝试 ping 的清单文件中或尝试在清单文件中添加插件,启用 ini 插件。enable_plugins = ini

于 2020-06-22T10:01:45.377 回答
0

我可以看到一些 mitogen 条目您是否在默认设置中使用 mitogen 作为 strategy_plugin?建议尝试在您的 ansible.cfg 文件中评论 (strategy_plugin, strategy)。

从日志的外观来看,您似乎正在运行 Ansible 版本 2.9.9。Mitogen 0.2.9 版似乎适用于 Ansible 2.3-2.8 以及 Python 2.6、2.7、3.6 和 3.7

验证 Mitogen 版本并尝试在 ansible.cfg 文件中对其进行注释

参考链接:https ://mitogen.networkgenomics.com/ansible_detailed.html#noteworthy-differences

于 2020-07-23T04:22:45.230 回答