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 logging
import os import os
import pprint
import random import random
import stat import stat
import time import time
@ -699,11 +700,16 @@ class Connection(ansible.plugins.connection.ConnectionBase):
representing the target. If no connection exists yet, ContextService representing the target. If no connection exists yet, ContextService
will establish it before returning it or throwing an error. will establish it before returning it or throwing an error.
""" """
dct = self.parent.call_service( try:
service_name='ansible_mitogen.services.ContextService', dct = self.parent.call_service(
method_name='get', service_name='ansible_mitogen.services.ContextService',
stack=mitogen.utils.cast(list(stack)), 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['msg']:
if dct['method_name'] in self.become_methods: if dct['method_name'] in self.become_methods:
@ -809,6 +815,10 @@ class Connection(ansible.plugins.connection.ConnectionBase):
self.broker = None self.broker = None
self.router = None self.router = None
reset_compat_msg = (
'Mitogen only supports "reset_connection" on Ansible 2.5.6 or later'
)
def reset(self): def reset(self):
""" """
Explicitly terminate the connection to the remote host. This discards 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 the 'disconnected' state, and informs ContextService the connection is
bad somehow, and should be shut down and discarded. 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._connect()
self._mitogen_reset(mode='reset') self._mitogen_reset(mode='reset')

@ -6,8 +6,15 @@
- name: integration/connection/reset.yml - name: integration/connection/reset.yml
hosts: test-targets hosts: test-targets
tasks: tasks:
- when: is_mitogen - meta: end_play
block: 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: - custom_python_detect_environment:
register: out register: out

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

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

Loading…
Cancel
Save