winrm:无法建立新连接 [Errno 110]

winrm : Failed to establish a new connection [Errno 110]

我看到我的 ansible win_psexec 任务在 windows 主机上启动,但是大约 14 分钟后连接丢失,任务失败,我不确定为什么。

任何 help\suggestions 非常感谢 - 谢谢。

ansible 日志看起来像是在任务执行大约 8 分钟后尝试启动新连接 运行。为什么?

这是我的任务:

>     - name: Run DVD installer 
>       win_psexec:
>         command: 'Z:\DVD\UniversalInstall.exe -UNATTENDED_INSTALL -SETTINGSFILE=Z:\SettingsFile_UniversalInstaller.xml'
>         username: rmautobuild
>         password: <password>
>         timeout: 7200
>         interactive: yes
>         system: yes

这是可靠的日志输出:

2018-09-30 16:42:42,621 p=3892 u=rmubuntu |  ansible-playbook 2.5.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/rmubuntu/.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-playbook
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
2018-09-30 16:42:42,622 p=3892 u=rmubuntu |  Using /etc/ansible/ansible.cfg as config file
2018-09-30 16:42:42,646 p=3892 u=rmubuntu |  Parsed /etc/ansible/hosts inventory source with ini plugin
2018-09-30 16:42:43,376 p=3892 u=rmubuntu |  PLAYBOOK: site.yml ****************************************************************************************************
2018-09-30 16:42:43,377 p=3892 u=rmubuntu |  1 plays in site.yml
2018-09-30 16:42:43,425 p=3892 u=rmubuntu |  PLAY [Install ACCS] ***************************************************************************************************
2018-09-30 16:42:43,448 p=3892 u=rmubuntu |  META: ran handlers
2018-09-30 16:42:43,457 p=3892 u=rmubuntu |  TASK [ACCS : Run DVD installer] ***************************************************************************************
2018-09-30 16:42:43,457 p=3892 u=rmubuntu |  task path: /etc/ansible/roles/ACCS/tasks/main.yml:9
2018-09-30 16:42:43,656 p=3892 u=rmubuntu |  Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_psexec.ps1
2018-09-30 16:42:43,670 urllib3.connectionpool Starting new HTTPS connection (1): 10.134.51.103:5986
2018-09-30 16:42:44,938 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 200 1626
2018-09-30 16:42:44,941 p=3892 u=rmubuntu |  EXEC (via pipeline wrapper)
2018-09-30 16:42:45,073 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 200 847
2018-09-30 16:42:54,558 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 200 753
2018-09-30 16:44:54,609 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 500 1320
2018-09-30 16:46:54,614 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 500 1320
2018-09-30 16:48:54,632 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 500 1320
2018-09-30 16:50:54,636 urllib3.connectionpool https://10.134.51.103:5986 "POST /wsman HTTP/1.1" 500 1320
2018-09-30 16:53:24,724 urllib3.connectionpool Starting new HTTPS connection (2): 10.134.51.103:5986
2018-09-30 16:55:35,031 urllib3.connectionpool Starting new HTTPS connection (3): 10.134.51.103:5986
2018-09-30 16:57:46,114 p=3892 u=rmubuntu |  The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 138, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 558, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py", line 46, in run
    result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 795, in _execute_module
    res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 902, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py", line 493, in exec_command
    result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True, stdin_iterator=stdin_iterator)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py", line 440, in _winrm_exec
    self.protocol.cleanup_command(self.shell_id, command_id)
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/winrm/protocol.py", line 372, in cleanup_command
    res = self.send_message(xmltodict.unparse(req))
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/winrm/protocol.py", line 234, in send_message
    resp = self.transport.send_message(message)
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/winrm/transport.py", line 256, in send_message
    response = self._send_message_request(prepared_request, message)
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/winrm/transport.py", line 261, in _send_message_request
    response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/rmubuntu/.local/lib/python2.7/site-packages/requests/adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='10.134.51.103', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f30ce143690>: Failed to establish a new connection: [Errno 110] Connection timed out',))

2018-09-30 16:57:46,116 p=3892 u=rmubuntu |  fatal: [10.134.51.103]: FAILED! => {
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

原来我通过 ansible 安装的应用程序正在主机上应用防火墙更改。它删除了允许 WinRM 的防火墙规则,因此中断了与 ansible 的连接。