update logic
This commit is contained in:
parent
8d6e24c460
commit
d1d2f2dc15
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue