community.general icon indicating copy to clipboard operation
community.general copied to clipboard

nmcli does not attempt to create connection

Open UnoSD opened this issue 7 months ago • 5 comments

Summary

   - name: Set up network
     community.general.nmcli:
       conn_name: Ethernet
       ifname: enp6s0
       type: ethernet
       method4: manual
       ip4: 192.168.1.2/24
       gw4: 192.168.1.1
       dns4:
         - 1.1.1.1
         - 1.0.0.1
       state: present
       autoconnect: yes

results in Error: unknown connection 'Ethernet'

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.18.4]
  config file = None
  configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.2 (main, Feb  5 2025, 08:05:21) [GCC 14.2.1 20250128] (/usr/bin/python)
  jinja version = 3.1.5
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/xxx/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 10.5.0 

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None

GALAXY_SERVERS:

OS / Environment

Ansible: Arch Linux Target: Debian 12

Steps to Reproduce

   - name: Set up network
     community.general.nmcli:
       conn_name: Ethernet
       ifname: enp6s0
       type: ethernet
       method4: manual
       ip4: 192.168.1.2/24
       gw4: 192.168.1.1
       dns4:
         - 1.1.1.1
         - 1.0.0.1
       state: present
       autoconnect: yes
ansible-playbook -i inventory.yaml playbook.yaml

Expected Results

Network interface created

Actual Results

Error: unknown connection 'Ethernet'

Code of Conduct

  • [x] I agree to follow the Ansible Code of Conduct

UnoSD avatar Apr 19 '25 06:04 UnoSD

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 avatar Apr 19 '25 06:04 ansibullbot

cc @alcamie101 click here for bot help

ansibullbot avatar Apr 19 '25 06:04 ansibullbot

turns out I forgot to add "become" to run as superuser. I can close this issue, however, I would like to suggest to add more meaningful error messages to the output if possible, shall I modify this issue or close and reopen a different one?

Thanks.

UnoSD avatar Apr 19 '25 11:04 UnoSD

I'm wondering whether nmcli is giving a better/proper error message that we're ignoring for some reason.

felixfontein avatar Apr 20 '25 19:04 felixfontein

hi @felixfontein, I checked and it does give you more details, it says "insufficient privileges".

UnoSD avatar Apr 20 '25 19:04 UnoSD