From f7064c672cb07b511112d26c0f52ec741e68aa34 Mon Sep 17 00:00:00 2001 From: Jonathan Mainguy Date: Mon, 18 May 2015 22:55:51 -0400 Subject: [PATCH] added nice error for systemd hosts where name > 64 chars --- system/hostname.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/hostname.py b/system/hostname.py index 307a8b687be..1fe16e506f4 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: