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:
parent
92544993c0
commit
682c6fc967
2 changed files with 8 additions and 2 deletions
2
changelogs/fragments/6048-nmcli-addres-order.yml
Normal file
2
changelogs/fragments/6048-nmcli-addres-order.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- nmcli - order is significant for lists of addresses (https://github.com/ansible-collections/community.general/pull/6048).
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue