From 2757333e844f597b85980093bddc52552ef73aa5 Mon Sep 17 00:00:00 2001 From: Kristian Klausen Date: Thu, 25 Feb 2021 17:12:17 +0100 Subject: archlinux: Use hostnamectl to set the transient hostname (#797) hostname (inetutils) isn't installed per default on arch, so switch to hostnamectl which is installed per default (systemd). --- cloudinit/distros/arch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cloudinit/distros/arch.py') diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py index 378a6daa..5f42a24c 100644 --- a/cloudinit/distros/arch.py +++ b/cloudinit/distros/arch.py @@ -137,6 +137,17 @@ class Distro(distros.Distro): return default return hostname + # hostname (inetutils) isn't installed per default on arch, so we use + # hostnamectl which is installed per default (systemd). + def _apply_hostname(self, hostname): + LOG.debug("Non-persistently setting the system hostname to %s", + hostname) + try: + subp.subp(['hostnamectl', '--transient', 'set-hostname', hostname]) + except subp.ProcessExecutionError: + util.logexc(LOG, "Failed to non-persistently adjust the system " + "hostname to %s", hostname) + def set_timezone(self, tz): distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz)) -- cgit v1.2.3