update logic

This commit is contained in:
Swapnil 2024-05-02 13:19:10 +05:30
parent 8d6e24c460
commit d1d2f2dc15
Signed by: swapnil
GPG Key ID: 58029C48BB100574
1 changed files with 16 additions and 6 deletions

View File

@ -179,14 +179,24 @@ def run_module():
argument_spec=module_args,
)
if module.params:
if module.check_mode:
module.result['changed'] = True
else:
current_config = module.get_call()
# Check for changes
changes = {key: module.params[key] for key in module.params if module.params.get(key) != current_config.get(key)}
if changes:
module.result['changed'] = True
module.result['changes'] = changes
# If not in check mode, apply the changes
if not module.check_mode:
module.patch_call(data=module.params)
# return the result as device_default from the API response
module.result['device_default'] = module.get_call()
# Get the updated configuration
module.result['device_default'] = module.get_call()
else:
module.result['changed'] = False
module.result['device_default'] = current_config
module.exit_json()