Skip to content

Commit

Permalink
Add an option for rhel to force the use of hostname config
Browse files Browse the repository at this point in the history
RHEL always use the FQDN as hostname thats the default
behavior, setting prefer_fqdn_over_hostname option to
to false will prefer the hostname over fqdn

LP: canonical#859
  • Loading branch information
hamzah alqtaishat authored and hamalq committed Apr 6, 2021
1 parent 3b7e2e8 commit 7df818b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloudinit/distros/rhel.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def _write_hostname(self, hostname, out_fn):
def _select_hostname(self, hostname, fqdn):
# Should be fqdn if we can use it
# See: https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-sysconfig.html#s2-sysconfig-network # noqa
if not util.get_cfg_option_bool(self._cfg, "prefer_fqdn_over_hostname", True) \
and hostname:
return hostname
if fqdn:
return fqdn
return hostname
Expand Down

0 comments on commit 7df818b

Please sign in to comment.