Import of local module_utils within local action_plugin not working

amartyasinha
Mon, 21 Jul 2025 11:12:48 +0000
Get Help

I had to use my custom collection in Zuul native playbook runs, but seems like it is not possible to install custom collection on zuul executor. So, I created a role similar to this to use my custom modules and action plugins in native Zuul playbooks.

The issue is, I’m able to import and use module_utils in modules, but it is not working in case of action_plugins.

Here is a sample role structure:

.
├── action_plugins
│   └── my_action1.py
├── library
│   └── my_module1.py
├── modules_utils
│   └── my_module_utils1.py
└── tasks
    └── main.yaml

When I call my_module1 within task, it is able to resolve it’s dependency from module_utils, but the same is not true for my_action1 action plugin. It fails with the following error:

ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.plugins.module_utils'

I’ve tried to import in two ways:

first as from ansible.module_utils.xyz import abc source

second as from ..module_utils.xyz import abc source
Both ways gave errors with action plugins, while modules worked.

I even tried adding this but even it didn’t work for me.

I’ve tried running this directly on Ansible version 2.15.13 on my laptop as well through Zuul executor which was using Ansible Version: 2.15.12, and the result was same.

Any guidance to use local module_utils within local action_plugins within a role would be appreciated.

6 posts - 4 participants