From 737789b1e3d213e11c3e1bf7d661d21b5a7b15bc Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 26 Mar 2023 09:46:35 +0200 Subject: [PATCH] [PR #6106/5ee68704 backport][stable-5] nmcli: fixed idempotency issue with 'may_fail4' when 'method' is 'disabled' (#6240) nmcli: fixed idempotency issue with 'may_fail4' when 'method' is 'disabled' (#6106) * nmcli: fixed idempotency issue with 'may_fail4' when 'method' is 'disabled' * added note to documentation * updated changelog fragment * Update changelog fragment. --------- Co-authored-by: Felix Fontein (cherry picked from commit 5ee687049f16d75b532eafe4c5404a8564a3a3f0) Co-authored-by: Sam Potekhin --- .../fragments/6106-nmcli-ipv4-mayfail-idempotency-fix.yml | 2 ++ plugins/modules/net_tools/nmcli.py | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 changelogs/fragments/6106-nmcli-ipv4-mayfail-idempotency-fix.yml diff --git a/changelogs/fragments/6106-nmcli-ipv4-mayfail-idempotency-fix.yml b/changelogs/fragments/6106-nmcli-ipv4-mayfail-idempotency-fix.yml new file mode 100644 index 0000000000..a444176155 --- /dev/null +++ b/changelogs/fragments/6106-nmcli-ipv4-mayfail-idempotency-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - nmcli - fixed idempotency issue when module params is set to ``may_fail4=false`` and ``method4=disabled``; in this case nmcli ignores change and keeps their own default value ``yes`` (https://github.com/ansible-collections/community.general/pull/6106). diff --git a/plugins/modules/net_tools/nmcli.py b/plugins/modules/net_tools/nmcli.py index 584064dbed..ea22601b79 100644 --- a/plugins/modules/net_tools/nmcli.py +++ b/plugins/modules/net_tools/nmcli.py @@ -190,6 +190,7 @@ options: may_fail4: description: - If you need I(ip4) configured before C(network-online.target) is reached, set this option to C(false). + - This option applies when C(method4) is not C(disabled). type: bool default: true version_added: 3.3.0 @@ -1569,6 +1570,10 @@ class Nmcli(object): 'ipv6.ip6-privacy': self.ip_privacy6, 'ipv6.addr-gen-mode': self.addr_gen_mode6 }) + # when 'method' is disabled the 'may_fail' no make sense but accepted by nmcli with keeping 'yes' + # force ignoring to save idempotency + if self.ipv4_method and self.ipv4_method != 'disabled': + options.update({'ipv4.may-fail': self.may_fail4}) # Layer 2 options. if self.mac: