ansible-collections / mellanox.onyx

onyx
GNU General Public License v3.0
10 stars 14 forks source link

No module named 'ansible.plugins.action.network' #10

Closed pavelion closed 3 years ago

pavelion commented 3 years ago
SUMMARY

mellanox.onyx.plugins.action.onyx_config imports ansible.plugins.action.network which is no longer available in Ansible 2.10

ISSUE TYPE
COMPONENT NAME

mellanox.onyx.plugins.action.onyx_config

ANSIBLE VERSION
ansible 2.10.1
  python version = 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27) [Clang 6.0 (clang-600.0.57)]
STEPS TO REPRODUCE
---
- hosts: mellanox_onyx
  gather_facts: false
  tasks:
    - mellanox.onyx.onyx_config:
        lines:
          - configuration write
EXPECTED RESULTS
ACTUAL RESULTS
PLAY [mellanox_onyx] *****************************************************************************************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.plugins.action.network'
ivangerasimov39 commented 3 years ago

I have same issue

ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.plugins.action.network' the full traceback was:

Traceback (most recent call last): File "/usr/local/bin/ansible-playbook", line 123, in exit_code = cli.run() File "/usr/local/lib/python3.6/site-packages/ansible/cli/playbook.py", line 128, in run results = pbex.run() File "/usr/local/lib/python3.6/site-packages/ansible/executor/playbook_executor.py", line 169, in run result = self._tqm.run(play=play) File "/usr/local/lib/python3.6/site-packages/ansible/executor/task_queue_manager.py", line 259, in run play_return = strategy.run(iterator, play_context) File "/usr/local/lib/python3.6/site-packages/ansible/plugins/strategy/linear.py", line 266, in run action = action_loader.get(task.action, class_only=True) File "/usr/local/lib/python3.6/site-packages/ansible/plugins/loader.py", line 780, in get return self.get_with_context(name, *args, **kwargs).object File "/usr/local/lib/python3.6/site-packages/ansible/plugins/loader.py", line 800, in get_with_context self._module_cache[path] = self._load_module_source(name, path) File "/usr/local/lib/python3.6/site-packages/ansible/plugins/loader.py", line 764, in _load_module_source spec.loader.exec_module(module) File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/root/ansible-cct/collections/ansible_collections/mellanox/onyx/plugins/action/onyx_config.py", line 22, in from ansible.plugins.action.network import ActionModule as ActionNetworkModule ModuleNotFoundError: No module named 'ansible.plugins.action.network'

stephenulmer commented 3 years ago

I also have this issue:

ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.plugins.action.network'
the full traceback was:

Traceback (most recent call last):
  File "/Users/ulmer/.pyenv/versions/3.8.0/bin/ansible-playbook", line 123, in <module>
    exit_code = cli.run()
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/cli/playbook.py", line 128, in run
    results = pbex.run()
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/executor/playbook_executor.py", line 169, in run
    result = self._tqm.run(play=play)
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 280, in run
    play_return = strategy.run(iterator, play_context)
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/plugins/strategy/linear.py", line 266, in run
    action = action_loader.get(task.action, class_only=True, collection_list=task.collections)
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/plugins/loader.py", line 780, in get
    return self.get_with_context(name, *args, **kwargs).object
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/plugins/loader.py", line 800, in get_with_context
    self._module_cache[path] = self._load_module_source(name, path)
  File "/Users/ulmer/.pyenv/versions/3.8.0/lib/python3.8/site-packages/ansible/plugins/loader.py", line 764, in _load_module_source
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/ulmer/.ansible/collections/ansible_collections/mellanox/onyx/plugins/action/onyx_config.py", line 22, in <module>
    from ansible.plugins.action.network import ActionModule as ActionNetworkModule
ModuleNotFoundError: No module named 'ansible.plugins.action.network'
stephenulmer commented 3 years ago

Hmmm... So if I move the mellanox/onyx/plugins/action/ directory out of the way, then it will work with a fully-qualified module name. Putting a collections section in the playbook does not let me use the short name. So it seems that this file is used for the module redirection somehow, but brakes everything because it can't be loaded...

I have looked for a couple of hours and can't figure out how to fix this the right way (I've never written an action plugin). I hope this bit is helpful to someone else.

cristeab commented 3 years ago

I have been able to solve this error by replacing in file "/root/ansible-cct/collections/ansible_collections/mellanox/onyx/plugins/action/onyx_config.py", line 22

from ansible.plugins.action.network import ActionModule as ActionNetworkModule

with

from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule

stephenulmer commented 3 years ago

You are correct! I’ll be testing that on a real switch on Monday, and hopefully it will be integrated by the maintainer soon!

-- Stephen

On Nov 25, 2020, at 8:33 AM, Bogdan Cristea notifications@github.com wrote:

I have been able to solve this error by replacing in file "/root/ansible-cct/collections/ansible_collections/mellanox/onyx/plugins/action/onyx_config.py", line 22

from ansible.plugins.action.network import ActionModule as ActionNetworkModule

with

from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ansible-collections/mellanox.onyx/issues/10#issuecomment-733708799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJNCUCSIPAF4WVNRFB55RUTSRUBSDANCNFSM4SJDIOQQ.

robertkley commented 5 months ago

Following cristeab's recommendation and editing the .../collections/ansible_collections/mellanox/onyx/plugins/action/onyx_config.py, line 22 with:

from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule

made everything work amazingly well again!