1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #6048/682c6fc9 backport][stable-5] nmcli: Treat order as significant when comparing address lists (#6081)

nmcli: Treat order as significant when comparing address lists (#6048)

* nmcli: Treat order as significant when comparing address lists

Don't sort the old and new values for ipv4.addresses and
ipv6.addresses before comparing them, because order matters in these
parameters: the first address specified is the default source address
for outbound connections.

* Changelog fragment for #6048

* Update changelogs/fragments/6048-nmcli-addres-order.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 682c6fc967)

Co-authored-by: Jonathan Kamens <jik@kamens.us>
This commit is contained in:
patchback[bot] 2023-02-25 11:29:41 +01:00 committed by GitHub
parent 170a099101
commit 1f5703d0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- nmcli - order is significant for lists of addresses (https://github.com/ansible-collections/community.general/pull/6048).

View file

@ -2137,8 +2137,12 @@ class Nmcli(object):
if isinstance(current_value, list) and isinstance(value, list):
# compare values between two lists
if sorted(current_value) != sorted(value):
changed = True
if key in ('ipv4.addresses', 'ipv6.addresses'):
# The order of IP addresses matters because the first one
# is the default source address for outbound connections.
changed |= current_value != value
else:
changed |= sorted(current_value) != sorted(value)
elif all([key == self.mtu_setting, self.type == 'dummy', current_value is None, value == 'auto', self.mtu is None]):
value = None
else: