Skip to content

Action plugin fetch fails when used inside a reimported role from a collection #971

@gboutry

Description

@gboutry
  • Which version of Ansible are you running?

    • 2.9.27 - mitogen 0.2.10
    • 2.10.17 - mitogen 0.3.3
  • Is your version of Ansible patched in any way?
    No

  • Are you running with any custom modules, or module_utils loaded?
    No

  • Have you tried the latest master version from Git?
    No

  • Do you have some idea of what the underlying problem may be?
    Yes, the

  • Mention your host and target OS and versions

    • My host: Fedora 36
    • Target: Centos 7
  • Mention your host and target Python versions

    • My Host: python3.6 when ansible 2.9, python3.10 when 2.10
    • Target: python2.7
  • If reporting a crash or hang in Ansible, please rerun with -vvv and include
    200 lines of output around the point of the error, along with a full copy of
    any traceback or error text in the log. Beware "-vvv" may include secret
    data! Edit as necessary before posting.
    The only important logs when running with verbose mode:

TASK [tosit.tdp_prerequisites.certificates : Fetch certificate authority's certificate] ******************************************************************************************************************************************************
fatal: [gboutry-master-01]: FAILED! => {}

MSG:

the handler 'fetch' was not found
  • If reporting any kind of problem with Ansible, please include the Ansible
    version along with output of "ansible-config dump --only-changed".

Possible solution

I found the root cause of the issue, it's because of ansible action plugin resolution when collections are involved that will create a candidate list with the name of plugin prepended with collections given in the argument collection_list.

This fails because the plugin mitogen_fetch is not from a collection. (fetch is renamed mitogen fetch).

The following solution works for me in 0.2.9 and 0.3.3:

diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py
index 0a98e316..257a4e31 100644
--- a/ansible_mitogen/strategy.py
+++ b/ansible_mitogen/strategy.py
@@ -88,7 +88,9 @@ def wrap_action_loader__get(name, *args, **kwargs):
     get_kwargs = {'class_only': True}
     if name in ('fetch',):
         name = 'mitogen_' + name
-    get_kwargs['collection_list'] = kwargs.pop('collection_list', None)
+        get_kwargs['collection_list'] = None
+    else:
+        get_kwargs['collection_list'] = kwargs.pop('collection_list', None)
 
     klass = ansible_mitogen.loaders.action_loader__get(name, **get_kwargs)
     if klass:

I'm ready to propose a pull request with the solution if you find the solution to be correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-0.2Issues related to 0.2.X Mitogen releasesbugCode feature that hinders desired execution outcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions