From dee960716b7fcc614abc8a99239fb911d1b71797 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Tue, 7 Jan 2014 14:21:22 -0500 Subject: [PATCH] Fixes #5353 create etc/hostname file in debian if it does not exist --- library/system/hostname | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/system/hostname b/library/system/hostname index 9aa7c206a4..8a9401d243 100644 --- a/library/system/hostname +++ b/library/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: