prefer_fqdn_over_hostname
is documented as,
If both
fqdn
andhostname
are set, it is distro dependent whetherhostname
orfqdn
is used, unless theprefer_fqdn_over_hostname
option istrue
andfqdn
is set it will force the use of FQDN in all distros, and if false then it will force thehostname
use.
In my cloud-init.cfg
I have,
hostname: "host-10-2-65-89"
fqdn: "host-10-2-65-89.openstack.build."
prefer_fqdn_over_hostname: true
But when I run this my hostname is set to host-10-2-65-89
. Here is the log, and you can see it explicitly says host-10-2-65-89.openstack.build.
249 - cc_set_hostname.py[DEBUG]: Setting the hostname to host-10-2-65-89.openstack.build. (host-10-2-65-89)
250 - util.py[DEBUG]: Reading from /etc/hostname (quiet=False)
250 - util.py[DEBUG]: Read 7 bytes from /etc/hostname
250 - util.py[DEBUG]: Writing to /etc/hostname - wb: [644] 16 bytes
250 - __init__.py[DEBUG]: Non-persistently setting the system hostname to host-10-2-65-89
250 - subp.py[DEBUG]: Running command ['hostname', 'host-10-2-65-89'] with allowed return codes [0] (shell=False, capture=True)
256 - atomic_helper.py[DEBUG]: Atomically writing to file /var/lib/cloud/data/set-hostname (via temporary file /var/lib/cloud/data/tmpaxqv667c) - w: [644] 80 bytes/chars
The contents of /var/lib/cloud/data/set-hostname
{
"fqdn": "host-10-2-65-89.openstack.build.",
"hostname": "host-10-2-65-89"
}
The contents of /var/lib/cloud/data/previous-hostname
host-10-2-65-89.openstack.build.
I'm using Cloud-init v. 21.4-0ubuntu1~20.04.1
I've tried deleting all but the FQDN and it still doesn't set the /etc/hostname
to the fqdn.