Skip to content

Commit a2dceda

Browse files
committed
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.
1 parent 36f3e3b commit a2dceda

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ansible_mitogen/planner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import logging
4242
import os
4343
import random
44+
import re
4445

4546
from ansible.executor import module_common
4647
from ansible.collections.list import list_collection_dirs
@@ -297,11 +298,11 @@ class NewStylePlanner(ScriptPlanner):
297298
preprocessing the module.
298299
"""
299300
runner_name = 'NewStyleRunner'
300-
marker = b'from ansible.module_utils.'
301+
MARKER = re.compile(b'from ansible(?:_collections|\.module_utils)\.')
301302

302303
@classmethod
303304
def detect(cls, path, source):
304-
return cls.marker in source
305+
return cls.MARKER.search(source) != None
305306

306307
def _get_interpreter(self):
307308
return None, None

0 commit comments

Comments
 (0)