Skip to content

Commit

Permalink
archlinux: Use hostnamectl to set the transient hostname (#797)
Browse files Browse the repository at this point in the history
hostname (inetutils) isn't installed per default on arch, so switch
to hostnamectl which is installed per default (systemd).
  • Loading branch information
klausenbusk authored Feb 25, 2021
1 parent 402d98e commit 2757333
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cloudinit/distros/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ def _read_hostname(self, filename, default=None):
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))

Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ johnsonshi
jordimassaguerpla
jqueuniet
jsf9k
klausenbusk
landon912
lucasmoura
lungj
Expand Down

0 comments on commit 2757333

Please sign in to comment.