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: state=present does not bring up interface #9790

Open
1 task done
leegarrett opened this issue Feb 21, 2025 · 3 comments
Open
1 task done

nmcli: state=present does not bring up interface #9790

leegarrett opened this issue Feb 21, 2025 · 3 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@leegarrett
Copy link
Contributor

Summary

Configuring a network interface using nmcli, and setting state=present will not bring up interface, contrary what documentation says. I noticed this on physical and virtual machines I configured via nmcli. Below is a minimal reproducer to run locally.

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.18.1]
  config file = /home/randall/Coding/gits-playbook/test_playbooks/ansible.cfg
  configured module search path = ['/home/randall/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/randall/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.2 (main, Feb  5 2025, 01:23:35) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.5
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 10.1.0 

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = /home/randall/Coding/gits-playbook/test_playbooks/ansible.cfg
DEFAULT_STDOUT_CALLBACK(/home/randall/Coding/gits-playbook/test_playbooks/ansible.cfg) = yaml
DIFF_ALWAYS(/home/randall/Coding/gits-playbook/test_playbooks/ansible.cfg) = True
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less

OS / Environment

Debian 13 trixie, Debian 12 bookworm

Steps to Reproduce

$ cat nmcli.yml
---
- hosts: localhost
  become: yes
  become_method: sudo
  connection: local
  tasks:
    - block:

        - name: create virtual interface
          command: 'ip link add veth99 type veth'

        - name: configure network interfaces
          nmcli:
            conn_name:      "testing_nmcli"
            conn_reload:    yes
            ifname:         veth99
            state:          present
            type:           ethernet
            ip6:    "dead:beef:dead:beef:dead:beef:dead:beef/128"
            method6: manual

        - name: Show interface config
          command: 'ip add show dev veth99'

      always:
        - name: Remove interface config
          nmcli:
            conn_name:      "testing_nmcli"
            conn_reload:    yes
            ifname:         veth99
            state:          absent

        - name: Delete virtual interface
          command: 'ip link del veth99'

$ ansible-playbook nmcli.yml -K -v

Expected Results

The 'Show interface config' showing the ipv6 address set on veth99.

Actual Results

Using /home/randall/Coding/gits-playbook/test_playbooks/ansible.cfg as config file
BECOME password: 
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] **********************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [create virtual interface] *******************************************************************************************************************************************************************************************************
changed: [localhost] => changed=true 
  cmd:
  - ip
  - link
  - add
  - veth99
  - type
  - veth
  delta: '0:00:00.004369'
  end: '2025-02-21 14:54:15.752893'
  msg: ''
  rc: 0
  start: '2025-02-21 14:54:15.748524'
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

TASK [configure network interfaces] ***************************************************************************************************************************************************************************************************
changed: [localhost] => changed=true 
  Connection: Connection testing_nmcli of Type ethernet is being added
  conn_name: testing_nmcli
  state: present
  stdout: |-
    Connection 'testing_nmcli' (9a4aac5d-fa16-4fa3-b556-15581cb637e1) successfully added.
  stdout_lines: <omitted>

TASK [Show interface config] **********************************************************************************************************************************************************************************************************
changed: [localhost] => changed=true 
  cmd:
  - ip
  - add
  - show
  - dev
  - veth99
  delta: '0:00:00.002752'
  end: '2025-02-21 14:54:16.463771'
  msg: ''
  rc: 0
  start: '2025-02-21 14:54:16.461019'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    228: veth99@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 0a:84:7e:4b:77:32 brd ff:ff:ff:ff:ff:ff
  stdout_lines: <omitted>

TASK [Remove interface config] ********************************************************************************************************************************************************************************************************
changed: [localhost] => changed=true 
  conn_name: testing_nmcli
  state: absent
  stdout: |-
    Connection 'testing_nmcli' (9a4aac5d-fa16-4fa3-b556-15581cb637e1) successfully deleted.
  stdout_lines: <omitted>

TASK [Delete virtual interface] *******************************************************************************************************************************************************************************************************
changed: [localhost] => changed=true 
  cmd:
  - ip
  - link
  - del
  - veth99
  delta: '0:00:00.045942'
  end: '2025-02-21 14:54:16.937349'
  msg: ''
  rc: 0
  start: '2025-02-21 14:54:16.891407'
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP ****************************************************************************************************************************************************************************************************************************
localhost                  : ok=6    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

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 Feb 21, 2025
@russoz
Copy link
Collaborator

russoz commented Feb 22, 2025

Hi @leegarrett thanks for reporting!

Just to be on the safe, could you please check whether that issue happens in the main branch of the repo, or at least in version 10.3.0? Just to make sure that it has not been addressed already. TIA

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

3 participants