summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_update_hostname.py
diff options
context:
space:
mode:
authorhamalq <81582959+hamalq@users.noreply.github.com>2021-04-15 16:45:12 -0700
committerGitHub <noreply@github.com>2021-04-15 18:45:12 -0500
commit45db197cfc7e3488baae7dc1053c45da070248f6 (patch)
tree91b0148c026c619e6f7f9f50064e6d07c1f47fac /cloudinit/config/cc_update_hostname.py
parent0d90596b56db5d306125ead08c571fc8d44d528e (diff)
downloadvyos-cloud-init-45db197cfc7e3488baae7dc1053c45da070248f6.tar.gz
vyos-cloud-init-45db197cfc7e3488baae7dc1053c45da070248f6.zip
add prefer_fqdn_over_hostname config option (#859)
the above option allows the user to control the behavior of a distro hostname selection if both short hostname and FQDN are supplied. If `prefer_fqdn_over_hostname` is true the FQDN will be selected as hostname; if false the hostname will be selected LP: #1921004
Diffstat (limited to 'cloudinit/config/cc_update_hostname.py')
-rw-r--r--cloudinit/config/cc_update_hostname.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cloudinit/config/cc_update_hostname.py b/cloudinit/config/cc_update_hostname.py
index d5f4eb5a..f4120356 100644
--- a/cloudinit/config/cc_update_hostname.py
+++ b/cloudinit/config/cc_update_hostname.py
@@ -27,6 +27,7 @@ is set, then the hostname will not be altered.
**Config keys**::
preserve_hostname: <true/false>
+ prefer_fqdn_over_hostname: <true/false>
fqdn: <fqdn>
hostname: <fqdn/hostname>
"""
@@ -45,6 +46,13 @@ def handle(name, cfg, cloud, log, _args):
" not updating the hostname in module %s"), name)
return
+ # Set prefer_fqdn_over_hostname value in distro
+ hostname_fqdn = util.get_cfg_option_bool(cfg,
+ "prefer_fqdn_over_hostname",
+ None)
+ if hostname_fqdn is not None:
+ cloud.distro.set_option('prefer_fqdn_over_hostname', hostname_fqdn)
+
(hostname, fqdn) = util.get_hostname_fqdn(cfg, cloud)
try:
prev_fn = os.path.join(cloud.get_cpath('data'), "previous-hostname")