Skip to content

nmcli not idempotent when checking connection state #9897

Open
@brad2014

Description

@brad2014

Summary

The following task to check whether a connection is up reports changed=true when the connection is in fact already up:

        - name: Assure connection is up
          register: nmcli_check
          community.general.nmcli:
            conn_name: "br0-eno1"
            state: up

It returns:

    "nmcli_check": {
        "changed": true,
        "conn_name": "br0-eno1",
        "failed": false,
        "state": "up",
        "stdout": "Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)\n",
        "stdout_lines": [
            "Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)"
        ]
    }

Possibility related to #7945.

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.18.3]
  config file = /Users/me/Projects/ansible/ansible.cfg
  configured module search path = ['/Users/me/Projects/ansible/homelab/roles/library', '/Users/me/Projects/ansible/homelab/roles/network/library']
  ansible python module location = /Users/me/Projects/ansible/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/me/Projects/ansible/collections
  executable location = /Users/me/Projects/ansible/.venv/bin/ansible
  python version = 3.13.2 (main, Feb  4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)] (/Users/me/Projects/ansible/.venv/bin/python3.13)
  jinja version = 3.1.5
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /Users/me/Projects/ansible/.venv/lib/python3.13/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 10.4.0 

Configuration

$ ansible-config dump --only-changed
ANSIBLE_NOCOLOR(/Users/me/Projects/ansible/ansible.cfg) = True
COLLECTIONS_PATHS(/Users/me/Projects/ansible/ansible.cfg) = ['/Users/me/Projects/ansible/collections']
CONFIG_FILE() = /Users/me/Projects/ansible/ansible.cfg
DEFAULT_FILTER_PLUGIN_PATH(/Users/me/Projects/ansible/ansible.cfg) = ['/Users/me/Projects/ansible/filter_plugins']
DEFAULT_GATHERING(/Users/me/Projects/ansible/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/Users/me/Projects/ansible/ansible.cfg) = ['/Users/me/Projects/ansible/inventories']
DEFAULT_LOAD_CALLBACK_PLUGINS(/Users/me/Projects/ansible/ansible.cfg) = True
DEFAULT_LOG_PATH(/Users/me/Projects/ansible/ansible.cfg) = /Users/me/Projects/ansible/ansible.log
DEFAULT_MODULE_PATH(/Users/me/Projects/ansible/ansible.cfg) = ['/Users/me/Projects/ansible/roles/library', '/Users/me/Projects/ansible/roles/network/library']
DEFAULT_NO_TARGET_SYSLOG(/Users/me/Projects/ansible/ansible.cfg) = True
DEFAULT_ROLES_PATH(/Users/me/Projects/ansible/ansible.cfg) = ['/Users/me/Projects/ansible/roles', '/Users/me/Projects/ansible/roles']
DIFF_ALWAYS(/Users/me/Projects/ansible/ansible.cfg) = True
INTERPRETER_PYTHON(/Users/me/Projects/ansible/ansible.cfg) = auto_silent
PERSISTENT_COMMAND_TIMEOUT(/Users/me/Projects/ansible/ansible.cfg) = 60

OS / Environment

Ansible controller: MacOS Sonoma 14.5
Target host: Rocky Linux 9.5

Steps to Reproduce

Run the task:

        - name: Assure connection is up
          register: nmcli_check
          community.general.nmcli:
            conn_name: "br0-eno1" # replace with an existing connection that is currently up
            state: up

Expected Results

The second run should report changed=False.

Actual Results

Every run reports changed=true.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodulepluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions