summaryrefslogtreecommitdiff
path: root/plugins/modules/vyos_hostname.py
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-03-20 21:50:13 +1000
committeromnom62 <omnom62@outlook.com>2026-03-20 21:50:13 +1000
commit7599ba96bc3b659cb2a5f00b1be46ab6f55f48a6 (patch)
tree35b39a126fe94f8917352aa2c229d3022d1223e4 /plugins/modules/vyos_hostname.py
parent9dc03bb92e08455812e0969505495309456a4bfb (diff)
downloadrest.vyos-7599ba96bc3b659cb2a5f00b1be46ab6f55f48a6.tar.gz
rest.vyos-7599ba96bc3b659cb2a5f00b1be46ab6f55f48a6.zip
precommit changes
Diffstat (limited to 'plugins/modules/vyos_hostname.py')
-rw-r--r--plugins/modules/vyos_hostname.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py
index f1c901e..9d70649 100644
--- a/plugins/modules/vyos_hostname.py
+++ b/plugins/modules/vyos_hostname.py
@@ -20,6 +20,7 @@ def get_running_config(vyos):
return {"hostname": hostname}
+
def build_commands(want, have, state):
commands = []
@@ -30,18 +31,22 @@ def build_commands(want, have, state):
if state in ["merged", "replaced", "overridden"]:
if want_host and want_host != have_host:
- commands.append({
- "op": "set",
- "path": ["system", "host-name", want_host]
- })
+ commands.append(
+ {
+ "op": "set",
+ "path": ["system", "host-name", want_host],
+ },
+ )
elif state == "deleted":
if have_host:
- commands.append({
- "op": "delete",
- "path": ["system", "host-name"]
- })
+ commands.append(
+ {
+ "op": "delete",
+ "path": ["system", "host-name"],
+ },
+ )
return commands
@@ -52,8 +57,8 @@ def main():
config=dict(
type="dict",
options=dict(
- hostname=dict(type="str")
- )
+ hostname=dict(type="str"),
+ ),
),
state=dict(
default="merged",
@@ -82,7 +87,7 @@ def main():
if state == "gathered":
module.exit_json(
changed=False,
- gathered=have
+ gathered=have,
)
commands = build_commands(want, have, state)
@@ -90,7 +95,7 @@ def main():
if module.check_mode:
module.exit_json(
changed=bool(commands),
- commands=commands
+ commands=commands,
)
if commands:
@@ -106,15 +111,15 @@ def main():
after=want,
commands=commands,
saved=saved,
- response=response
+ response=response,
)
module.exit_json(
changed=False,
before=have,
- after=have
+ after=have,
)
if __name__ == "__main__":
- main() \ No newline at end of file
+ main()