ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
784 stars 1.45k forks source link

nmcli fails to set method to "disabled" or "ignore" for ipv6 when ipv6 addresses already exist in the config #8565

Open tlskinneriv opened 6 days ago

tlskinneriv commented 6 days ago

Summary

When setting the method for IPv6 to "disabled" or "ignore", and there are IPv6 addresses already defined in the config, the module cannot set the new method. May need to have a condition to remove the addresses from the config before setting the method to allow this to work properly. This may extend past addresses and include gateway or routes as well, but I have not performed any additional testing. This may also extend to IPv4 method setting to "disabled" as well.

Issue Type

Bug Report

Component Name

nmcli

Ansible Version

$ ansible --version
ansible [core 2.14.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.16 (main, Dec 21 2022, 10:57:18) [GCC 8.5.0 20210514 (Red Hat 8.5.0-17)] (/usr/bin/python3.9)
  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 9.0.1

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg

OS / Environment

RHEL 9.4

Steps to Reproduce

- name: Set an ipv6 address
  community.general.nmcli:
    conn_name: ens192
    ip6: "::1"
    state: present

- name: Set ipv6 method to disabled
  community.general.nmcli:
    conn_name: ens192
    method6: disabled
    state: present

Expected Results

ipv6.method to be set to "disabled" or "ignore" successfully. If the connection has existing ipv6 addresses configured, they would be removed.

Actual Results

Error: Failed to modify connection 'ens192': ipv6.addresses: this property is not allowed for 'method=disabled'\n
Error: Failed to modify connection 'ens192': ipv6.addresses: this property is not allowed for 'method=ignore'\n

Code of Conduct

ansibullbot commented 6 days ago

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 commented 6 days ago

cc @alcamie101 click here for bot help