From c3671c4e3e2ad7efa119982f2ee41334fcacd073 Mon Sep 17 00:00:00 2001 From: omnom62 Date: Wed, 15 Apr 2026 07:24:24 +1000 Subject: Rest API module --- plugins/modules/vyos_ntp_global.py | 47 ++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'plugins/modules/vyos_ntp_global.py') diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py index d970142..bcfdd3b 100644 --- a/plugins/modules/vyos_ntp_global.py +++ b/plugins/modules/vyos_ntp_global.py @@ -362,23 +362,52 @@ def main(): # diff engine # -------------------------------------------------------- - commands = build_commands(desired, existing, state) + # commands = build_commands(desired, existing, state) - result["before"] = existing + # result["before"] = existing - result["commands"] = commands + # result["commands"] = commands - if commands: + # if commands: + + # result["changed"] = True + + # if not module.check_mode: - result["changed"] = True + # vyos.apply_commands(commands) - if not module.check_mode: + # result["after"] = desired - vyos.apply_commands(commands) + # module.exit_json(**result) - result["after"] = desired + commands = build_commands(desired, existing, state) + + if module.check_mode: + module.exit_json( + changed=bool(commands), + commands=commands, + before=existing, + ) - module.exit_json(**result) + if commands: + response = vyos.apply_commands(commands) + saved = vyos.save_config() + + module.exit_json( + changed=True, + before=existing, + after=desired, + commands=commands, + saved=saved, + response=response, + ) + + module.exit_json( + changed=False, + before=existing, + after=existing, + commands=[], + ) if __name__ == "__main__": -- cgit v1.2.3