summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-09-14 19:03:19 +1000
committeromnom62 <omnom62@outlook.com>2026-09-14 19:03:19 +1000
commitda624a86b8067ca730985d77c99922d08c6a8aa9 (patch)
tree534033a504fb2c8af57e435a2ad5f3b7b5148f45 /plugins
parent07ad54804c5509aee4b4856e0c48ff6d7f2194c2 (diff)
downloadrest.vyos-da624a86b8067ca730985d77c99922d08c6a8aa9.tar.gz
rest.vyos-da624a86b8067ca730985d77c99922d08c6a8aa9.zip
T8989: vyos_hostname AI comments fixed
Diffstat (limited to 'plugins')
-rw-r--r--plugins/modules/vyos_hostname.py7
1 files changed, 6 insertions, 1 deletions
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)