summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 07f03159..c6427401 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -128,8 +128,16 @@ class Distro(object):
raise NotImplementedError()
def _apply_hostname(self, hostname):
- LOG.debug("Setting system hostname to %s", hostname)
- util.subp(['hostname', hostname])
+ # This really only sets the hostname
+ # temporarily (until reboot so it should
+ # not be depended on). Use the write
+ # hostname functions for 'permanent' adjustments.
+ LOG.debug("Temporarily setting the system hostname to %s", hostname)
+ try:
+ util.subp(['hostname', hostname])
+ except util.ProcessExecutionError:
+ util.logexc(LOG, ("Failed to temporarily adjust"
+ " the system hostname to %s"), hostname)
def update_hostname(self, hostname, prev_hostname_fn):
if not hostname: