From b61788bfea2c0aaceda57aabbddbb3d1f21fcf8e Mon Sep 17 00:00:00 2001 From: Georgina Shippey Date: Wed, 17 Feb 2021 18:16:17 +0000 Subject: [PATCH] Make OpenStack collections qualify for NewStylePlanner To be detected as a NewStyle module mitogen expects that your module imports ansible.module_utils. However the OpenStack collections modules import a utility module which then imports ansible.module_utils. Due to the naive way mitogen checks for this import the Openstack collections modules do not qualify currently as being NewStyle as there is a layer of abstraction, therefore causing them to fail down the line as they are run with the OldStylePlanner. My fix is as equally naive! --- ansible_mitogen/planner.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible_mitogen/planner.py b/ansible_mitogen/planner.py index faf8d197..61156482 100644 --- a/ansible_mitogen/planner.py +++ b/ansible_mitogen/planner.py @@ -301,6 +301,9 @@ class NewStylePlanner(ScriptPlanner): @classmethod def detect(cls, path, source): + if b'from ansible_collections.openstack.' in source: + cls.marker = b'from ansible_collections.openstack.' + LOG.debug('cls.marker: %r, source: %r', cls.marker, source) return cls.marker in source def _get_interpreter(self):