From 46dde959620524b76ec2723cafe3fa54ee170c75 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 26 May 2019 12:06:14 +0100 Subject: [PATCH] issue #587: 2.8 PlayContext.connection no longer contains connection name Not clear what the intention is here. Either need to ferret it out of some other location, or just stop preloading the connection class in the top-level process. --- ansible_mitogen/strategy.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py index 3c7ea687..5521e127 100644 --- a/ansible_mitogen/strategy.py +++ b/ansible_mitogen/strategy.py @@ -40,6 +40,12 @@ import ansible_mitogen.process import ansible import ansible.executor.process.worker +try: + # 2.8+ has a standardized "unset" object. + from ansible.utils.sentinel import Sentinel +except ImportError: + Sentinel = None + ANSIBLE_VERSION_MIN = '2.3' ANSIBLE_VERSION_MAX = '2.8' @@ -261,14 +267,17 @@ class StrategyMixin(object): name=task.action, mod_type='', ) - ansible_mitogen.loaders.connection_loader.get( - name=play_context.connection, - class_only=True, - ) ansible_mitogen.loaders.action_loader.get( name=task.action, class_only=True, ) + if play_context.connection is not Sentinel: + # 2.8 appears to defer computing this value until it's inside the + # worker. TODO: figure out where this value has moved. + ansible_mitogen.loaders.connection_loader.get( + name=play_context.connection, + class_only=True, + ) return super(StrategyMixin, self)._queue_task( host=host,