Ansible + WinRM部署问题-request.exceptions.ChunkedEncodingError :(“连接断开:ConnectionResetError(104,'由对等方重置连接'))

时间:2019-10-31 17:30:33

标签: python-3.x ansible winrm

尝试在远程Windows服务器上使用Ansible进行部署时遇到问题。

很难识别出该问题偶尔在不同的服务器上发生

没有网络问题发生,所以无法理解连接重置的情况

ansible 2.8.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /bin/ansible
  python version = 3.6.5 (default, Apr 10 2018, 17:08:37) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
17:38:06            TASK [Publish] *****************************************************************
17:38:06            task path: /opt/ansible/playbooks/deploy/my-site/site_deploy.yml:98
17:38:06            Using module file /usr/lib/python3.6/site-packages/ansible/modules/windows/win_shell.ps1
17:38:06            Pipelining is enabled.
17:38:06            <us2.my.com> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO us2.my.com
17:38:07            EXEC (via pipeline wrapper)
17:38:13            The full traceback is:
17:38:13            Traceback (most recent call last):
17:38:13              File "/usr/lib/python3.6/site-packages/urllib3/response.py", line 302, in _error_catcher
17:38:13                yield
17:38:13              File "/usr/lib/python3.6/site-packages/urllib3/response.py", line 384, in read
17:38:13                data = self._fp.read(amt)
17:38:13              File "/usr/lib64/python3.6/http/client.py", line 449, in read
17:38:13                n = self.readinto(b)
17:38:13              File "/usr/lib64/python3.6/http/client.py", line 493, in readinto
17:38:13                n = self.fp.readinto(b)
17:38:13              File "/usr/lib64/python3.6/socket.py", line 586, in readinto
17:38:13                return self._sock.recv_into(b)
17:38:13              File "/usr/lib64/python3.6/ssl.py", line 1009, in recv_into
17:38:13                return self.read(nbytes, buffer)
17:38:13              File "/usr/lib64/python3.6/ssl.py", line 871, in read
17:38:13                return self._sslobj.read(len, buffer)
17:38:13              File "/usr/lib64/python3.6/ssl.py", line 631, in read
17:38:13                v = self._sslobj.read(len, buffer)
17:38:13            ConnectionResetError: [Errno 104] Connection reset by peer
17:38:13            
17:38:13            During handling of the above exception, another exception occurred:
17:38:13            
17:38:13            Traceback (most recent call last):
17:38:13              File "/usr/lib/python3.6/site-packages/requests/models.py", line 750, in generate
17:38:13                for chunk in self.raw.stream(chunk_size, decode_content=True):
17:38:13              File "/usr/lib/python3.6/site-packages/urllib3/response.py", line 436, in stream
17:38:13                data = self.read(amt=amt, decode_content=decode_content)
17:38:13              File "/usr/lib/python3.6/site-packages/urllib3/response.py", line 401, in read
17:38:13                raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

17:38:13              File "/usr/lib64/python3.6/contextlib.py", line 99, in __exit__
17:38:13                self.gen.throw(type, value, traceback)
17:38:13              File "/usr/lib/python3.6/site-packages/urllib3/response.py", line 320, in _error_catcher
17:38:13                raise ProtocolError('Connection broken: %r' % e, e)
17:38:13            urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
17:38:13            
17:38:13            During handling of the above exception, another exception occurred:
17:38:13            
17:38:13            Traceback (most recent call last):
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 144, in run
17:38:13                res = self._execute()
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 648, in _execute
17:38:13                result = self._handler.run(task_vars=variables)
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/plugins/action/normal.py", line 46, in run
17:38:13                result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 917, in _execute_module
17:38:13                res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 1060, in _low_level_execute_command
17:38:13                rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/winrm.py", line 535, in exec_command
17:38:13                result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True, stdin_iterator=stdin_iterator)
17:38:13              File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/winrm.py", line 462, in _winrm_exec
17:38:13                resptuple = self.protocol.get_command_output(self.shell_id, command_id)
17:38:13              File "/usr/lib/python3.6/site-packages/winrm/protocol.py", line 398, in get_command_output
17:38:13                self._raw_get_command_output(shell_id, command_id)
17:38:13              File "/usr/lib/python3.6/site-packages/winrm/protocol.py", line 417, in _raw_get_command_output
17:38:13                res = self.send_message(xmltodict.unparse(req))
17:38:13              File "/usr/lib/python3.6/site-packages/winrm/protocol.py", line 234, in send_message
17:38:13                resp = self.transport.send_message(message)
17:38:13              File "/usr/lib/python3.6/site-packages/winrm/transport.py", line 256, in send_message
17:38:13                response = self._send_message_request(prepared_request, message)
17:38:13              File "/usr/lib/python3.6/site-packages/winrm/transport.py", line 261, in _send_message_request
17:38:13                response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
17:38:13              File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 686, in send
17:38:13                r.content
17:38:13              File "/usr/lib/python3.6/site-packages/requests/models.py", line 828, in content
17:38:13                self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
17:38:13              File "/usr/lib/python3.6/site-packages/requests/models.py", line 753, in generate
17:38:13                raise ChunkedEncodingError(e)
17:38:13            requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
17:38:13            fatal: [us2]: FAILED! => {
17:38:13                "msg": "Unexpected failure during module execution.",
17:38:13                "stdout": ""
17:38:13            }

0 个答案:

没有答案