Repository: ansible-collections/community.general

Issue:
nmcli changes to addr_gen_mode6 choices in newer os versions
### Summary

Valid choices for addr_gen_mode6 in the nmcli module are found:
https://github.com/ansible-collections/community.general/blob/main/plugins/modules/nmcli.py#L295
https://github.com/ansible-collections/community.general/blob/main/plugins/modules/nmcli.py#L2247

From the nm-settings-nmcli man page on RHEL 8.7 / Fedora 37 / (RHEL 9.?), there are now additional values:

>    ipv6 setting
>        IPv6 Settings.
> 
>        Properties:
> 
>        addr-gen-mode
>            Configure method for creating the address for use with RFC4862 IPv6 Stateless Address Autoconfiguration. The permitted values are: NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64 (0),
>            NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY (1). NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_DEFAULT_OR_EUI64 (2) or NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_DEFAULT (3).
> 
>            If the property is set to EUI64, the addresses will be generated using the interface tokens derived from hardware address. This makes the host part of the address to stay constant, making it possible to track
>            host's presence when it changes networks. The address changes when the interface hardware is replaced.
> 
>            The value of stable-privacy enables use of cryptographically secure hash of a secret host-specific key along with the connection's stable-id and the network address as specified by RFC7217. This makes it impossible
>            to use the address track host's presence, and makes the address stable when the network interface hardware is replaced.
> 
>            The special values "default" and "default-or-eui64" will fallback to the global connection default in as documented in NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is
>            "stable-privacy" or "eui64", respectively.
> 
>            For libnm, the property defaults to "default" since 1.40. Previously it defaulted to "stable-privacy". On D-Bus, the absence of an addr-gen-mode setting equals "default". For keyfile plugin, the absence of the
>            setting on disk means "default-or-eui64" so that the property doesn't change on upgrade from older versions.
> 
>            Note that this setting is distinct from the Privacy Extensions as configured by "ip6-privacy" property and it does not affect the temporary addresses configured with this option.
> 
>            Format: int32
> 




### Issue Type

Bug Report

### Component Name

nmcli

### Ansible Version

```console (paste below)
# ansible --version
ansible [core 2.14.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.13 (main, Nov  9 2022, 13:16:24) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True


```


### Community.general Version

```console (paste below)
# ansible-galaxy collection list community.general -p collections

# /root/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.3.0  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

RHEL 8.7

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
# cat nmcli.yml 
---
- name: test nmcli
  hosts: all
  tasks:
  - name: dns search order is set
    community.general.nmcli:
      conn_name: "System {{ ansible_facts.default_ipv4.interface }}"
      type: ethernet
      state: present
      dns4_search: example.org
      addr_gen_mode6: default-or-eui64

```


### Expected Results

Update nmcli with valid settings per man page.

### Actual Results

```console (paste below)
TASK [dns search order is set] ********************************************************************************************************************************************************************************************************
fatal: [sattower01]: FAILED! => changed=false 
  msg: 'value of addr_gen_mode6 must be one of: eui64, stable-privacy, got: default-or-eui64'

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:

Resolving patch:
diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py
--- a/plugins/modules/nmcli.py
+++ b/plugins/modules/nmcli.py
@@ -295,8 +295,9 @@
     addr_gen_mode6:
         description:
             - Configure method for creating the address for use with IPv6 Stateless Address Autoconfiguration.
+            - C(default) and C(deafult-or-eui64) have been added in community.general 6.5.0.
         type: str
-        choices: [eui64, stable-privacy]
+        choices: [default, default-or-eui64, eui64, stable-privacy]
         version_added: 4.2.0
     mtu:
         description:
@@ -2244,7 +2245,7 @@ def main():
             route_metric6=dict(type='int'),
             method6=dict(type='str', choices=['ignore', 'auto', 'dhcp', 'link-local', 'manual', 'shared', 'disabled']),
             ip_privacy6=dict(type='str', choices=['disabled', 'prefer-public-addr', 'prefer-temp-addr', 'unknown']),
-            addr_gen_mode6=dict(type='str', choices=['eui64', 'stable-privacy']),
+            addr_gen_mode6=dict(type='str', choices=['default', 'default-or-eui64', 'eui64', 'stable-privacy']),
             # Bond Specific vars
             mode=dict(type='str', default='balance-rr',
                       choices=['802.3ad', 'active-backup', 'balance-alb', 'balance-rr', 'balance-tlb', 'balance-xor', 'broadcast']),


Test patch:
diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py
--- a/tests/unit/plugins/modules/test_nmcli.py
+++ b/tests/unit/plugins/modules/test_nmcli.py
@@ -3916,7 +3916,7 @@ def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd):
             route_metric6=dict(type='int'),
             method6=dict(type='str', choices=['ignore', 'auto', 'dhcp', 'link-local', 'manual', 'shared', 'disabled']),
             ip_privacy6=dict(type='str', choices=['disabled', 'prefer-public-addr', 'prefer-temp-addr', 'unknown']),
-            addr_gen_mode6=dict(type='str', choices=['eui64', 'stable-privacy']),
+            addr_gen_mode6=dict(type='str', choices=['default', 'default-or-eui64', 'eui64', 'stable-privacy']),
             # Bond Specific vars
             mode=dict(type='str', default='balance-rr',
                       choices=['802.3ad', 'active-backup', 'balance-alb', 'balance-rr', 'balance-tlb', 'balance-xor', 'broadcast']),