diff --git a/system/hostname b/system/hostname index 9aa7c206a4b..8a9401d2436 100644 --- a/system/hostname +++ b/system/hostname @@ -146,6 +146,12 @@ class DebianStrategy(GenericStrategy): HOSTNAME_FILE = '/etc/hostname' def get_permanent_hostname(self): + if not os.path.isfile(self.HOSTNAME_FILE): + try: + open(self.HOSTNAME_FILE, "a").write("") + except IOError, err: + self.module.fail_json(msg="failed to write file: %s" % + str(err)) try: f = open(self.HOSTNAME_FILE) try: