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 isn't idempotent when setting a connection's state to down #9200

Open
1 task done
joshmcorreia opened this issue Nov 27, 2024 · 2 comments
Open
1 task done

nmcli isn't idempotent when setting a connection's state to down #9200

joshmcorreia opened this issue Nov 27, 2024 · 2 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@joshmcorreia
Copy link

Summary

When setting a connection's state to "down" using the nmcli module, the task fails if the connection is already down.

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.17.6]
  config file = None
  configured module search path = ['/home/josh/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/josh/venvs/ansible_environment/lib/python3.10/site-packages/ansible
  ansible collection location = /home/josh/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/josh/venvs/ansible_environment/bin/ansible
  python version = 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] (/home/josh/venvs/ansible_environment/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/josh/venvs/ansible_environment/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 9.5.1

Configuration

No response

OS / Environment

The target system is running RHEL 9.4, the host system is running Ubuntu 22.04.5.

Steps to Reproduce

- name: Disable all enp* connections
  community.general.nmcli:
    conn_name: "{{ item }}"
    state: down
  when: ansible_facts[item]['device'].startswith("enp")
  loop: "{{ ansible_facts.interfaces }}"

Expected Results

I expect this playbook to succeed when the state of the devices is already disconnected, but instead it fails saying that the connection is not active.

Actual Results

$ ansible-playbook -i inventory.yaml set_up_network_interfaces.yaml
...
TASK [Disable all enp* connections] ******************************************************************************************************
skipping: [metal] => (item=lo)
failed: [metal] (item=enp129s0f0np0) => {"ansible_loop_var": "item", "changed": false, "item": "enp129s0f0np0", "msg": "Error: 'enp129s0f0np0' is not an active connection.\nError: no active connection provided.\n", "name": "No Connection named enp129s0f0np0 exists", "rc": 10}
failed: [metal] (item=enp129s0f1np1) => {"ansible_loop_var": "item", "changed": false, "item": "enp129s0f1np1", "msg": "Error: 'enp129s0f1np1' is not an active connection.\nError: no active connection provided.\n", "name": "No Connection named enp129s0f1np1 exists", "rc": 10}
skipping: [metal] => (item=eno1)

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) labels Nov 27, 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)
Projects
None yet
Development

No branches or pull requests

2 participants