Merge remote-tracking branch 'origin/dmw'

Tset fixes.
issue260
David Wilson 6 years ago
commit 123d267e57

@ -31,6 +31,7 @@ from __future__ import unicode_literals
import logging
import os
import pprint
import random
import stat
import time
@ -699,11 +700,16 @@ class Connection(ansible.plugins.connection.ConnectionBase):
representing the target. If no connection exists yet, ContextService
will establish it before returning it or throwing an error.
"""
try:
dct = self.parent.call_service(
service_name='ansible_mitogen.services.ContextService',
method_name='get',
stack=mitogen.utils.cast(list(stack)),
)
except mitogen.core.CallError:
LOG.warning('Connection failed; stack configuration was:\n%s',
pprint.pformat(stack))
raise
if dct['msg']:
if dct['method_name'] in self.become_methods:
@ -809,6 +815,10 @@ class Connection(ansible.plugins.connection.ConnectionBase):
self.broker = None
self.router = None
reset_compat_msg = (
'Mitogen only supports "reset_connection" on Ansible 2.5.6 or later'
)
def reset(self):
"""
Explicitly terminate the connection to the remote host. This discards
@ -816,6 +826,13 @@ class Connection(ansible.plugins.connection.ConnectionBase):
the 'disconnected' state, and informs ContextService the connection is
bad somehow, and should be shut down and discarded.
"""
if self._play_context.remote_addr is None:
# <2.5.6 incorrectly populate PlayContext for reset_connection
# https://github.com/ansible/ansible/issues/27520
raise ansible.errors.AnsibleConnectionFailure(
self.reset_compat_msg
)
self._connect()
self._mitogen_reset(mode='reset')

@ -6,8 +6,15 @@
- name: integration/connection/reset.yml
hosts: test-targets
tasks:
- when: is_mitogen
block:
- meta: end_play
when: not is_mitogen
- debug: msg="reset.yml skipped on Ansible<2.5.6"
when: ansible_version.full < '2.5.6'
- meta: end_play
when: ansible_version.full < '2.5.6'
- custom_python_detect_environment:
register: out

@ -1,6 +1,6 @@
# Ensure paramiko connections aren't grabbed.
- name: integration/connection_loader__paramiko_unblemished.yml
- name: integration/connection_loader/paramiko_unblemished.yml
hosts: test-targets
any_errors_fatal: true
tasks:

@ -22,6 +22,7 @@
'docker_path': None,
'kind': 'lxc',
'lxc_info_path': None,
'lxc_path': None,
'machinectl_path': None,
'python_path': None,
'username': None,

Loading…
Cancel
Save