Ansible 停止通过 ssh 连接到主机

Ansible stops connecting to the host via ssh

简介

一个多月以来,我一直在运行执行以下命令:

ansible-playbook -vvvvi host_test rhel-tests.yml

通过 SSH 连接并且 运行 在主机上测试成功,没有任何问题。 但是截至最近几天,我在 运行ning:

时收到了以下信息
fatal: [10.2.16.2]: UNREACHABLE! => {
    "changed": false, 
    "unreachable": true
}

MSG:

Failed to connect to the host via ssh: OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 35742
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Control master terminated unexpectedly
Shared connection to 10.2.16.2 closed.

尽管我可以从主机建立从 bash 到 10.2.16.2 的正常 SSH 连接,但我 运行ning.

详情

host_test内容如下:

[rhel]
10.2.16.2 node_type=xxx

[rhel:vars]
ansible_become=yes
ansible_become_method=su
ansible_become_user=root
ansible_connection=ssh
ansible_user=yyy
node_name=""


[cisco]

[cisco:vars]
node_name=""

[curtiss-wright]

[zzz]

[other]

[nmap:children]
rhel
cisco
curtiss-wright
other
zzz

[password-test]

这是我的 ansible.cfg:

[defaults]
ask_vault_pass = True
filter_plugins = filter_plugins
host_key_checking = False
retry_files_enabled = False
inventory = hosts
stdout_callback = debug

[paramiko_connection]
record_host_keys=False

[ssh_connection]
ssh_args = -o LogLevel=QUIET -o ControlMaster=auto -o ControlPersist=2m -o UserKnownHostsFile=/dev/null
scp_if_ssh = True

我的想法

问题

是什么导致我的 playbook 失败,我该如何解决?

由于您的游戏没有输出,连接可能会中断。

将以下内容添加到 ansible.cfg 中的 ssh_args

-o ServerAliveInterval=50