From 7ba3d84004f2db5d855ad4930e9b61e1004bb80c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:50:53 +0100 Subject: [PATCH] [PR #9880/3922b82a backport][stable-10] nmcli: fix reordering of DNS nameservers and search suffixes (#9912) nmcli: fix reordering of DNS nameservers and search suffixes (#9880) * nmcli: fix reordering of DNS nameservers and search suffixes - Fixes #8724 * Update changelog fragment index in line with PR number - Now I understand what that number is for * Use correct changelog format for nmcli PR #9880 (cherry picked from commit 3922b82a571adbe4a2cc7dcaf8910b0b27107b88) Co-authored-by: ashleyghooper --- ...nmcli-fix-reorder-same-dns-nameservers-search-suffixes.yml | 2 ++ plugins/modules/nmcli.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/9880-nmcli-fix-reorder-same-dns-nameservers-search-suffixes.yml diff --git a/changelogs/fragments/9880-nmcli-fix-reorder-same-dns-nameservers-search-suffixes.yml b/changelogs/fragments/9880-nmcli-fix-reorder-same-dns-nameservers-search-suffixes.yml new file mode 100644 index 0000000000..cefa79f387 --- /dev/null +++ b/changelogs/fragments/9880-nmcli-fix-reorder-same-dns-nameservers-search-suffixes.yml @@ -0,0 +1,2 @@ +bugfixes: + - "nmcli - enable changing only the order of DNS servers or search suffixes (https://github.com/ansible-collections/community.general/issues/8724, https://github.com/ansible-collections/community.general/pull/9880)." diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 623546dae4..3c895e76ec 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -2514,9 +2514,11 @@ class Nmcli(object): if isinstance(current_value, list) and isinstance(value, list): # compare values between two lists - if key in ('ipv4.addresses', 'ipv6.addresses'): + if key in ('ipv4.addresses', 'ipv6.addresses', 'ipv4.dns', 'ipv6.dns', 'ipv4.dns-search', 'ipv6.dns-search'): # The order of IP addresses matters because the first one # is the default source address for outbound connections. + # Similarly, the order of DNS nameservers and search + # suffixes is important. changed |= current_value != value else: changed |= sorted(current_value) != sorted(value)