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

nmcli error while adding mac to existing connection #5290

Closed
1 task done
giorgiga opened this issue Sep 17, 2022 · 3 comments · Fixed by #5291
Closed
1 task done

nmcli error while adding mac to existing connection #5290

giorgiga opened this issue Sep 17, 2022 · 3 comments · Fixed by #5291
Labels
bug This issue/PR relates to a bug check-before-release PR will be looked at again shortly before release and merged if possible. has_pr module module net_tools plugins plugin (any type) traceback

Comments

@giorgiga
Copy link
Contributor

Summary

Adding a mac address to an exisitng and previously mac-less connection errors out, because value is None and code calls upper() on it.

Traceback (most recent call last):
File "/home/user/.ansible/tmp/ansible-tmp-1663420215.47344-164730-139061857592873/AnsiballZ_nmcli.py", line 107, in <module>
    _ansiballz_main()
File "/home/user/.ansible/tmp/ansible-tmp-1663420215.47344-164730-139061857592873/AnsiballZ_nmcli.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/user/.ansible/tmp/ansible-tmp-1663420215.47344-164730-139061857592873/AnsiballZ_nmcli.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.net_tools.nmcli', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.net_tools.nmcli', _modlib_path=modlib_path),
File "/usr/lib64/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
File "/tmp/ansible_community.general.nmcli_payload_5wdkozfd/ansible_community.general.nmcli_payload.zip/ansible_collections/community/general/plugins/modules/net_tools/nmcli.py", line 2368, in <module>
File "/tmp/ansible_community.general.nmcli_payload_5wdkozfd/ansible_community.general.nmcli_payload.zip/ansible_collections/community/general/plugins/modules/net_tools/nmcli.py", line 2330, in main
File "/tmp/ansible_community.general.nmcli_payload_5wdkozfd/ansible_community.general.nmcli_payload.zip/ansible_collections/community/general/plugins/modules/net_tools/nmcli.py", line 2143, in is_connection_changed
File "/tmp/ansible_community.general.nmcli_payload_5wdkozfd/ansible_community.general.nmcli_payload.zip/ansible_collections/community/general/plugins/modules/net_tools/nmcli.py", line 2095, in _compare_conn_params
AttributeError: 'NoneType' object has no attribute 'upper'

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.12.7]
  config file = /home/giorgio/Projects/infra/ansible.cfg
  configured module search path = ['/home/giorgio/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/giorgio/Projects/infra/galaxy/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, Aug  2 2022, 00:00:00) [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)]
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

Collection        Version
----------------- -------
community.general 5.5.0  

Configuration

no relevant changes to default config

OS / Environment

Fedora f36 (irrelevant)

Steps to Reproduce

  1. create a new connection with community.general.nmcli (or by other means) without assigning a mac
  2. use community.general.nmcli to assign a mac

Expected Results

it should work

Actual Results

(see error above)

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module net_tools plugins plugin (any type) traceback labels Sep 17, 2022
@giorgiga
Copy link
Contributor Author

The issue is around line 2098 of nmcli.py:

if key == self.mac_setting:
    # MAC addresses are case insensitive, nmcli always reports them in uppercase
    value = value.upper()
    # ensure current_value is also converted to uppercase in case nmcli changes behaviour
    current_value = current_value.upper()

@felixfontein felixfontein changed the title nmcli error while adding mac to exisitng connection nmcli error while adding mac to existing connection Sep 18, 2022
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-4 labels Sep 18, 2022
felixfontein added a commit that referenced this issue Sep 28, 2022
* fix #5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
patchback bot pushed a commit that referenced this issue Sep 28, 2022
* fix #5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit ec9e10d)
felixfontein pushed a commit that referenced this issue Sep 28, 2022
…5318)

* fix #5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit ec9e10d)

Co-authored-by: Giorgio Gallo <[email protected]>
cfiehe pushed a commit to cfiehe/community.general that referenced this issue Sep 29, 2022
…ollections#5291)

* fix ansible-collections#5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
…ollections#5291)

* fix ansible-collections#5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
…ollections#5291)

* fix ansible-collections#5290

* add changelog fragment

* remove unnecessary braces

* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug check-before-release PR will be looked at again shortly before release and merged if possible. has_pr module module net_tools plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants