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

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>
This commit is contained in:
Jonathan Kamens 2023-02-25 05:00:43 -05:00 committed by GitHub
parent 92544993c0
commit 682c6fc967
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

@ -2144,8 +2144,12 @@ class Nmcli(object):
if isinstance(current_value, list) and isinstance(value, list): if isinstance(current_value, list) and isinstance(value, list):
# compare values between two lists # compare values between two lists
if sorted(current_value) != sorted(value): if key in ('ipv4.addresses', 'ipv6.addresses'):
changed = True # 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]): elif all([key == self.mtu_setting, self.type == 'dummy', current_value is None, value == 'auto', self.mtu is None]):
value = None value = None
else: else: