From 81b16a88ee4d8e2433dca7f323e22bca2d37c6ac Mon Sep 17 00:00:00 2001 From: Sam Potekhin Date: Sun, 26 Mar 2023 14:28:51 +0700 Subject: [PATCH] nmcli: fixed idempotency issue when config bridge connection (#6105) * nmcli: fixed idempotency issue when config bridge connection * Update changelog fragment. --------- Co-authored-by: Felix Fontein --- changelogs/fragments/3216-nmcli-bridge-idempotency-fix.yml | 2 ++ plugins/modules/nmcli.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/3216-nmcli-bridge-idempotency-fix.yml diff --git a/changelogs/fragments/3216-nmcli-bridge-idempotency-fix.yml b/changelogs/fragments/3216-nmcli-bridge-idempotency-fix.yml new file mode 100644 index 0000000000..130800b6da --- /dev/null +++ b/changelogs/fragments/3216-nmcli-bridge-idempotency-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - nmcli - fixed idempotency issue for bridge connections. Module forced default value of ``bridge.priority`` to nmcli if not set; if ``bridge.stp`` is disabled nmcli ignores it and keep default (https://github.com/ansible-collections/community.general/issues/3216, https://github.com/ansible-collections/community.general/issues/4683). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 0a9eff8da1..d967ddd446 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -1629,6 +1629,10 @@ class Nmcli(object): 'bridge.priority': self.priority, 'bridge.stp': self.stp, }) + # priority make sense when stp enabed, otherwise nmcli keeps bridge-priority to 32768 regrdless of input. + # force ignoring to save idempotency + if self.stp: + options.update({'bridge.priority': self.priority}) elif self.type == 'team': options.update({ 'team.runner': self.runner,