Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors after migrating to ansible 2.10 #247

Open
iaalmeida opened this issue Mar 30, 2021 · 2 comments
Open

Errors after migrating to ansible 2.10 #247

iaalmeida opened this issue Mar 30, 2021 · 2 comments

Comments

@iaalmeida
Copy link

iaalmeida commented Mar 30, 2021

ISSUE TYPE

  • Bug Report

ANSIBLE VERSION

ansible --version
ansible 2.10.7

ansible-galaxy list | grep ansible.network
- ansible-network.network-engine, v2.7.5

Network OS

  • Debian GNU/Linux 10

SUMMARY

After upgrade ansible from 2.9.18 to 2.10, I was no longer able to run my playbooks with network-engine.

The error was "ModuleNotFoundError: No module named 'ansible.module_utils.network_common'"

In file

  ~/.ansible/roles/ansible-network.network-engine/action_plugins/command_parser.py

I had to change line 26

  from ansible.module_utils.network_common import to_list

to

  from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list

And in file:

  ~/.ansible/roles/ansible-network.network-engine/lib/network_engine/utils.py

I had to change line 13

  from ansible.module_utils.network.common.utils import sort_list

to

  from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import sort_list

STEPS TO REPRODUCE

---
- hosts: branches
  gather_facts: no

  tasks:
    - name: import the network-engine role
      import_role:
        name: ansible-network.network-engine

    - name: Generate global_facts as JSON
      command_parser:
        file: my_parsers.yml
        content: "{{ inventory_hostname }} "

EXPECTED RESULTS

No errors at all.

ACTUAL RESULTS

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

Traceback (most recent call last):
  File "~/.ansible/roles/ansible-network.network-engine/action_plugins/command_parser.py", line 23, in <module>
    from ansible.module_utils.network.common.utils import to_list
ModuleNotFoundError: No module named 'ansible.module_utils.network'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/.venvs/ansible-3.1/bin/ansible-playbook", line 123, in <module>
    exit_code = cli.run()
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/cli/playbook.py", line 129, in run
    results = pbex.run()
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/executor/playbook_executor.py", line 169, in run
    result = self._tqm.run(play=play)
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/executor/task_queue_manager.py", line 281, in run
    play_return = strategy.run(iterator, play_context)
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/plugins/strategy/linear.py", line 267, in run
    action = action_loader.get(task.action, class_only=True, collection_list=task.collections)
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/plugins/loader.py", line 782, in get
    return self.get_with_context(name, *args, **kwargs).object
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/plugins/loader.py", line 802, in get_with_context
    self._module_cache[path] = self._load_module_source(name, path)
  File "~/.venvs/ansible-3.1/lib/python3.7/site-packages/ansible/plugins/loader.py", line 766, in _load_module_source
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "~/.ansible/roles/ansible-network.network-engine/action_plugins/command_parser.py", line 26, in <module>
    from ansible.module_utils.network_common import to_list
ModuleNotFoundError: No module named 'ansible.module_utils.network_common'
@zendritic
Copy link

I have this same issue.

@jvanderaa
Copy link

@iaalmeida @zendritic take a look at https://docs.ansible.com/ansible/latest/network/user_guide/cli_parsing.html

This is effectively retired and moved into the Ansible netcommon libraries.

Issue #246 was opened to have this repo marked as archive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants