summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorKristian Klausen <kristian@klausen.dk>2021-02-25 17:12:17 +0100
committerGitHub <noreply@github.com>2021-02-25 11:12:17 -0500
commit2757333e844f597b85980093bddc52552ef73aa5 (patch)
tree1328efe3dd111879bc714f112d6996d75d04a2d9 /cloudinit
parent402d98edaa3a266bd5fab2b3a10d716346da6eb9 (diff)
downloadvyos-cloud-init-2757333e844f597b85980093bddc52552ef73aa5.tar.gz
vyos-cloud-init-2757333e844f597b85980093bddc52552ef73aa5.zip
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).
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/arch.py11
1 files changed, 11 insertions, 0 deletions
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))