← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~goneri/cloud-init:freebsd_hostname into cloud-init:master

 

Gonéri Le Bouder has proposed merging ~goneri/cloud-init:freebsd_hostname into cloud-init:master.

Commit message:
freebsd: apply the hostname
    
Define the _apply_hostname() method for the FreeBSD distribution.
Without this change, the hostname is correctly set in the /etc/rc.conf,
but the hostname is not reloaded.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~goneri/cloud-init/+git/cloud-init/+merge/365631
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~goneri/cloud-init:freebsd_hostname into cloud-init:master.
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
index ff22d56..9506e09 100644
--- a/cloudinit/distros/freebsd.py
+++ b/cloudinit/distros/freebsd.py
@@ -155,6 +155,14 @@ class Distro(distros.Distro):
     def _write_hostname(self, hostname, filename):
         self.updatercconf('hostname', hostname)
 
+    def _apply_hostname(self, hostname):
+        LOG.info("Changing the hostname to %s", hostname)
+        try:
+            util.subp(['hostname', hostname])
+        except Exception as e:
+            util.logexc(LOG, "Failed to change the hostname to %s", hostname)
+            raise e
+
     def create_group(self, name, members):
         group_add_cmd = ['pw', '-n', name]
         if util.is_group(name):

Follow ups