Add an option to use short hostname in RHEL

Bug #1921004 reported by hamza
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Low
Unassigned

Bug Description

cloud init with RHEL always use the FQDN over the hostname even if the hostname is sent like below
#cloud-config
---
hostname: shortname

the problem with always using the FQDN as hostname is the linux constrain on hostname length

getconf HOST_NAME_MAX
64

the FQDN is used for DNS and the DNS servers has no limit on that but using as hostname raise an error when cloud init try to set the hostname and fail cloud init

an option should be provided for RHEL like below

#cloud-config
---
enable_shortname: true

to change the default behavior from FQDN to the
1. hostname if send
2. short hostname from the FQDN

and the /etc/resolv.conf
search <domain>

so if the hostname is test.domain.com

the hostname will be *test*
and the
/etc/resolv.conf
search domain.com

Revision history for this message
hamza (alqtaishat) wrote :
Revision history for this message
hamza (alqtaishat) wrote :

or we can check if the FQDN > 64 and set the hostname
since it will fail the cloud init any way

Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks for the bug Hamze and for making cloud-init better.

I feel like this is a reasonable and concise request for a bug fix. Hamza, do you have the ability to run `cloud-init collect-logs` on an affected instance to show the Traceback that occurs with fqdn on RedHat is > 64 or the invalid behavior on such as system when trying to resolve hostanmes?

Note that `cloud-inig collect-`logs collects /var/log/cloud-init.log or userdata, if you specify custom passwords or something in userdata you may want to redact that from the logs before attaching them to this bug.

Revision history for this message
Chad Smith (chad.smith) wrote :

What I imagine is we could add smarts to rhel.py if len(fqdn) > HOST_NAME_MAX then use 'hostname' if present in userdata. Then we wouldn't have to change default behavior on anything except broken systems.

James Falcon (falcojr)
Changed in cloud-init:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
James Falcon (falcojr) wrote : Fixed in cloud-init version 21.2.

This bug is believed to be fixed in cloud-init in version 21.2. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers