diff --git a/changelogs/fragments/55595-nios-zone-idempotency-fix.yaml b/changelogs/fragments/55595-nios-zone-idempotency-fix.yaml new file mode 100644 index 00000000000..dfa8bd2dca2 --- /dev/null +++ b/changelogs/fragments/55595-nios-zone-idempotency-fix.yaml @@ -0,0 +1,2 @@ +bugfixes: +- To fix the nios_zone module idempotency failure - https://github.com/ansible/ansible/pull/55595 diff --git a/lib/ansible/module_utils/net_tools/nios/api.py b/lib/ansible/module_utils/net_tools/nios/api.py index 056a16138ad..bf4a061b1c3 100644 --- a/lib/ansible/module_utils/net_tools/nios/api.py +++ b/lib/ansible/module_utils/net_tools/nios/api.py @@ -447,8 +447,8 @@ class WapiModule(WapiBase): temp = ib_spec['restart_if_needed'] del ib_spec['restart_if_needed'] ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=ib_spec.keys()) - # reinstate restart_if_needed key if it's set to true in play - if module.params['restart_if_needed']: + # reinstate restart_if_needed if ib_obj is none, meaning there's no existing nios_zone ref + if not ib_obj: ib_spec['restart_if_needed'] = temp elif (ib_obj_type == NIOS_MEMBER): # del key 'create_token' as nios_member get_object fails with the key present