aur/issue587.patch
2019-05-27 15:50:44 +02:00

104 lines
4 KiB
Diff

diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml
index dc5f716..588a3b8 100644
--- a/.ci/azure-pipelines.yml
+++ b/.ci/azure-pipelines.yml
@@ -87,3 +87,9 @@ jobs:
#VER: 2.6.2
#DISTROS: debian
#STRATEGY: linear
+
+ Vanilla_280_27:
+ python.version: '2.7'
+ MODE: ansible
+ VER: 2.8.0
+ DISTROS: debian
diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py
index b9211fc..b6b9aaf 100644
--- a/ansible_mitogen/strategy.py
+++ b/ansible_mitogen/strategy.py
@@ -40,9 +40,15 @@ 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.7'
+ANSIBLE_VERSION_MAX = '2.8'
NEW_VERSION_MSG = (
"Your Ansible version (%s) is too recent. The most recent version\n"
"supported by Mitogen for Ansible is %s.x. Please check the Mitogen\n"
@@ -115,7 +121,11 @@ def wrap_action_loader__get(name, *args, **kwargs):
This is used instead of static subclassing as it generalizes to third party
action modules outside the Ansible tree.
"""
- klass = action_loader__get(name, class_only=True)
+ get_kwargs = {'class_only': True}
+ if ansible.__version__ >= '2.8':
+ get_kwargs['collection_list'] = kwargs.pop('collection_list', None)
+
+ klass = action_loader__get(name, **get_kwargs)
if klass:
bases = (ansible_mitogen.mixins.ActionModuleMixin, klass)
adorned_klass = type(str(name), bases, {})
@@ -261,14 +271,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 until inside the worker.
+ # TODO: figure out where it has moved.
+ ansible_mitogen.loaders.connection_loader.get(
+ name=play_context.connection,
+ class_only=True,
+ )
return super(StrategyMixin, self)._queue_task(
host=host,
diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py
index ad1cab3..d5f15b1 100644
--- a/ansible_mitogen/transport_config.py
+++ b/ansible_mitogen/transport_config.py
@@ -380,8 +380,9 @@ class PlayContextSpec(Spec):
for term in ansible.utils.shlex.shlex_split(
first_true((
self._play_context.become_flags,
- self._play_context.sudo_flags,
- # Ansible 2.3.
+ # Ansible <=2.7.
+ getattr(self._play_context, 'sudo_flags', ''),
+ # Ansible <=2.3.
getattr(C, 'DEFAULT_BECOME_FLAGS', ''),
getattr(C, 'DEFAULT_SUDO_FLAGS', '')
), default='')
diff --git a/tests/ansible/integration/async/runner_one_job.yml b/tests/ansible/integration/async/runner_one_job.yml
index ca798a7..3b14fa3 100644
--- a/tests/ansible/integration/async/runner_one_job.yml
+++ b/tests/ansible/integration/async/runner_one_job.yml
@@ -37,7 +37,12 @@
- result1.ansible_job_id == job1.ansible_job_id
- result1.attempts <= 100000
- result1.changed == True
- - result1.cmd == "sleep 1;\n echo alldone"
+ - |
+ # ansible/b72e989e1837ccad8dcdc926c43ccbc4d8cdfe44
+ (ansible_version.full >= '2.8' and
+ result1.cmd == "sleep 1;\necho alldone\n") or
+ (ansible_version.full < '2.8' and
+ result1.cmd == "sleep 1;\n echo alldone")
- result1.delta|length == 14
- result1.start|length == 26
- result1.finished == 1