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

Setting NMCLI wifi psk-flags always reports a change (when there should be none), psk-flags expects list of strings not integers #9121

Open
1 task done
bnerickson opened this issue Nov 11, 2024 · 2 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) traceback

Comments

@bnerickson
Copy link

Summary

If I try to setup a wifi connection profile with psk-flags set to "1" when psk-flags is already set to "1" on the existing connection profile, then ansible reports a change has been made even though no change should be made.

Also, maybe related: at the time of this writing the documentation and Network Manager API state that "psk-flags" should be a list of integers; but execution fails with an error that the list should be composed of strings if an integer list is used.

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

# ansible --version
ansible [core 2.14.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /bin/ansible
  python version = 3.9.18 (main, Oct  4 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

# ansible-galaxy collection list community.general

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 8.6.0  

Configuration

# ansible-config dump --only-changed
CALLBACKS_ENABLED(/etc/ansible/ansible.cfg) = ['foreman']
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False

OS / Environment

The server running Ansible is Rocky Linux 9:

# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"

The PC the wifi network connection creation attempt is made is Fedora KDE Workstation 41:

$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="41 (KDE Plasma)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=41
VERSION_CODENAME=""
PLATFORM_ID="platform:f41"
PRETTY_NAME="Fedora Linux 41 (KDE Plasma)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:41"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f41/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=41
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=41
SUPPORT_END=2025-12-15
VARIANT="KDE Plasma"
VARIANT_ID=kde

Steps to Reproduce

  1. To reproduce the psk-flags issue:
- name: Create wireless connection
  become: true
  hosts: devices
  tasks:
  - name: "Add wireless ssid nmcli connection"
    nmcli:
      addr_gen_mode6: stable-privacy
      autoconnect: yes
      conn_name: "ssid_name"
      ifname: "wlo1"
      ip_privacy6: disabled
      method4: auto
      method6: auto
      ssid: "ssid_name"
      state: present
      type: wifi
      wifi:
        powersave: 2
      wifi_sec:
        auth-alg: open
        fils: 2
        group:
          - ccmp
        key-mgmt: sae
        pairwise:
          - ccmp
        pmf: 3
        psk-flags:
          - "1"
    diff: true

Save this to test_wireless.yml.

Run the following command twice. ansible-playbook -i hosts test_wireless.yml -vvv

Every subsequent execution should result in a diff even though no changes should/need be made.

  1. To reproduce the "integer, but should be string error" which may or may not be related to this issue:
- name: Create wireless connection
  become: true
  hosts: devices
  tasks:
  - name: "Add wireless ssid nmcli connection"
    nmcli:
      addr_gen_mode6: stable-privacy
      autoconnect: yes
      conn_name: "ssid_name"
      ifname: "wlo1"
      ip_privacy6: disabled
      method4: auto
      method6: auto
      ssid: "ssid_name"
      state: present
      type: wifi
      wifi:
        powersave: 2
      wifi_sec:
        auth-alg: open
        fils: 2
        group:
          - ccmp
        key-mgmt: sae
        pairwise:
          - ccmp
        pmf: 3
        psk-flags:
          - 1
    diff: true

Save this to test_wireless2.yml and execute it with the following command: ansible-playbook -i hosts test_wireless.yml -vvv

Expected Results

  1. I expected psk-flags to NOT report nor apply any change to the network connection profile when the same flags are set on every invocation.

  2. I expected psk-flags to be a list of integers, but it expects strings instead.

Actual Results

  1. When using the same value for psk-flags, ansible reports a change and diff even though no observable change should occur:
--- before
+++ after
@@ -10,7 +10,7 @@
     ],
     "802-11-wireless-security.pmf": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
     "802-11-wireless-security.psk-flags": [
-        "******** (agent-owned)"
+        "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
     ],
     "802-11-wireless.powersave": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
     "802-11-wireless.ssid": "ssid_name",
  1. When specifying psk-flags as a list of integers, the following error occurs:
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.nmcli', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.nmcli', _modlib_path=modlib_path),
  File "/usr/lib64/python3.9/runpy.py", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 2669, in <module>
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 2641, in main
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 2235, in modify_connection
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 2196, in connection_update
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 1947, in connection_options
  File "/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py", line 2099, in list_to_string
TypeError: sequence item 0: expected str instance, int found
fatal: [***]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to *** closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1731362593.5422006-1090995-80250802680489/AnsiballZ_nmcli.py\", line 47, in invoke_module\r\n    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.nmcli', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.nmcli', _modlib_path=modlib_path),\r\n  File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 2669, in <module>\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 2641, in main\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 2235, in modify_connection\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 2196, in connection_update\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 1947, in connection_options\r\n  File \"/tmp/ansible_nmcli_payload_nd_x0qw0/ansible_nmcli_payload.zip/ansible_collections/community/general/plugins/modules/nmcli.py\", line 2099, in list_to_string\r\nTypeError: sequence item 0: expected str instance, int found\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

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 plugins plugin (any type) traceback labels Nov 11, 2024
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 module module plugins plugin (any type) traceback
Projects
None yet
Development

No branches or pull requests

2 participants