From da624a86b8067ca730985d77c99922d08c6a8aa9 Mon Sep 17 00:00:00 2001 From: omnom62 Date: Mon, 14 Sep 2026 19:03:19 +1000 Subject: T8989: vyos_hostname AI comments fixed --- plugins/modules/vyos_hostname.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins/modules') diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py index 3218333..b7bdd50 100644 --- a/plugins/modules/vyos_hostname.py +++ b/plugins/modules/vyos_hostname.py @@ -149,6 +149,8 @@ def main(): state = "merged" config = module.params.get("config") or {} + if state == "merged" and not config.get("hostname"): + module.fail_json(msg="config.hostname must be a non-empty string") try: current = get_running_config(vyos) @@ -163,7 +165,10 @@ def main(): commands = build_commands(config, current, state) if module.check_mode: - module.exit_json(changed=bool(commands), commands=commands, before=have, after=have) + # Matches the established convention across the rest of the + # collection: omit "after" entirely in check mode, rather than + # reporting have as if it were the post-change state. + module.exit_json(changed=bool(commands), commands=commands, before=have) if commands: response = vyos.apply_commands(commands) -- cgit v1.2.3