← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~d-info-e/cloud-init:freebsd-hostname-fqdn into cloud-init:master

 

do3meli has proposed merging ~d-info-e/cloud-init:freebsd-hostname-fqdn into cloud-init:master.

Commit message:
set hostname to FQDN on FreeBSD.

FreeBSD requires the hostname to be set to FQDN. Previously the hostname just got set to short hostname (without FQDN part). Now cloud-init does set the hostname to the FQDN on FreeBSD hosts if a valid FQDN is given.

LP: #1753499

Requested reviews:
  cloud-init commiters (cloud-init-dev)
Related bugs:
  Bug #1753499 in cloud-init: "hostname in FreeBSD should prefere FQDN"
  https://bugs.launchpad.net/cloud-init/+bug/1753499

For more details, see:
https://code.launchpad.net/~d-info-e/cloud-init/+git/cloud-init/+merge/340757

FreeBSD requires the hostname to be set to FQDN. Previously the hostname just got set to short hostname (without FQDN part). Now cloud-init does set the hostname to the FQDN if a valid FQDN is given.
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~d-info-e/cloud-init:freebsd-hostname-fqdn into cloud-init:master.
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
index aa468bc..88cb86d 100644
--- a/cloudinit/distros/freebsd.py
+++ b/cloudinit/distros/freebsd.py
@@ -132,6 +132,13 @@ class Distro(distros.Distro):
         LOG.debug("Using network interface %s", bsddev)
         return bsddev
 
+    def _select_hostname(self, hostname, fqdn):
+        # Should be fqdn if we can use it
+        # See: https://www.freebsd.org/cgi/man.cgi?query=rc.conf&sektion=5&manpath=FreeBSD+11.1-RELEASE+and+Ports # noqa
+        if fqdn:
+            return fqdn
+        return hostname
+
     def _read_system_hostname(self):
         sys_hostname = self._read_hostname(filename=None)
         return ('rc.conf', sys_hostname)