summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Mainguy <jon@soh.re>2015-05-18 22:55:51 -0400
committerToshio Kuratomi <toshio@fedoraproject.org>2015-05-20 18:03:23 -0700
commit0290c674b0e5f0b9e34c8e1ccf0fa9da74c4ced3 (patch)
treec88e786b4564b8682a18ef479b7e525693df9fe7
parent571dd73e702f67a57a78d30ed973c0ac607554b7 (diff)
downloadansible-modules-core-0290c674b0e5f0b9e34c8e1ccf0fa9da74c4ced3.tar.gz
added nice error for systemd hosts where name > 64 chars
-rw-r--r--system/hostname.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/system/hostname.py b/system/hostname.py
index 307a8b68..1fe16e50 100644
--- a/system/hostname.py
+++ b/system/hostname.py
@@ -248,6 +248,8 @@ class SystemdStrategy(GenericStrategy):
return out.strip()
def set_current_hostname(self, name):
+ if len(name) > 64:
+ self.module.fail_json(msg="name cannot be longer than 64 characters on systemd servers, try a shorter name")
cmd = ['hostnamectl', '--transient', 'set-hostname', name]
rc, out, err = self.module.run_command(cmd)
if rc != 0:
@@ -263,6 +265,8 @@ class SystemdStrategy(GenericStrategy):
return out.strip()
def set_permanent_hostname(self, name):
+ if len(name) > 64:
+ self.module.fail_json(msg="name cannot be longer than 64 characters on systemd servers, try a shorter name")
cmd = ['hostnamectl', '--pretty', 'set-hostname', name]
rc, out, err = self.module.run_command(cmd)
if rc != 0: