From a2dcedabda398e80b6bde84de38e3fa08f52956a Mon Sep 17 00:00:00 2001 From: Philippe Kueck Date: Thu, 1 Jul 2021 11:21:33 +0200 Subject: [PATCH 1/2] fixes #827 some ansible collections write their own module classes derived from ansible.module_utils.basic.AnsibleModule, thus lacking that import in the plugin file. NewStylePlanner was unable to detect these plugins as Ansiballz. This commit extends the search pattern for NewStylePlanner to also detect ansible_collections imports. --- ansible_mitogen/planner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible_mitogen/planner.py b/ansible_mitogen/planner.py index c0913a3e..a17189a3 100644 --- a/ansible_mitogen/planner.py +++ b/ansible_mitogen/planner.py @@ -41,6 +41,7 @@ import json import logging import os import random +import re from ansible.executor import module_common from ansible.collections.list import list_collection_dirs @@ -297,11 +298,11 @@ class NewStylePlanner(ScriptPlanner): preprocessing the module. """ runner_name = 'NewStyleRunner' - marker = b'from ansible.module_utils.' + MARKER = re.compile(b'from ansible(?:_collections|\.module_utils)\.') @classmethod def detect(cls, path, source): - return cls.marker in source + return cls.MARKER.search(source) != None def _get_interpreter(self): return None, None From bdbc9fe827b338ffdfb3106c83926e2f63c3159a Mon Sep 17 00:00:00 2001 From: Philippe Kueck Date: Thu, 1 Jul 2021 11:30:27 +0200 Subject: [PATCH 2/2] changelog entry for #827 --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 21d5d1a3..dacd2f93 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ v0.3.0 (unreleased) This release separates itself from the v0.2.X releases. Ansible's API changed too much to support backwards compatibility so from now on, v0.2.X releases will be for Ansible < 2.10 and v0.3.X will be for Ansible 2.10+. `See here for details `_. +* :gh:issue:`827` NewStylePlanner: detect `ansible_collections` imports * :gh:issue:`770` better check for supported Ansible version * :gh:issue:`731` ansible 2.10 support * :gh:issue:`652` support for ansible collections import hook