canonical / canonical/cloud-init

cloud-init non FQDN hostname not working as expected on AlmaLinux

Open
#4,656 2 comments 2 reactions 0 assignees View on GitHub
bug incomplete
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
The configuration of non-Fully Qualified Domain Name (FQDN) hostnames seems to be encountering issues on AlmaLinux and other distributions based on RHEL8, such as Rocky Linux and CentOS 8.

When setting up a hostname like `almalinux.lan`, cloud-init successfully configures the system hostname. However, when using a non-FQDN hostname like `almalinux`, cloud-init fails to configure it properly, leaving the hostname as `localhost`.

## Steps to reproduce the problem

1. AlmaLinux image created with Packer utility on Proxmox, latest version of cloud-init installed from repo with command `dnf install cloud-init -y`
2. In Proxmox right click on created image, selected **Clone image**.
3. In new window setup `Name` and click **Clone**
![2023-12-03_10h36_51](https://github.com/canonical/cloud-init/assets/20167720/ad8320a5-e2b7-45b2-aa2f-89f9096928e6)
4. Proxmox created Cloud-init disk with name `cidata` with following content of user-data
![2023-12-03_10h41_59](https://github.com/canonical/cloud-init/assets/20167720/d6ecdc10-e4fb-465a-85ed-c026356c5174)
5. Started Linux

What I understand is that user-data is different.
In case of **almalinux.lan**, `fqdn` key in **user-data** was created by Proxmox. Hostname was correctly set up .
In case of **almalinux**, no `fqdn` key in **user-data** was created by Proxmox. Hostname was not correctly set up .

## user-data of almalinux.lan
```
#cloud-config
hostname: almalinux
manage_etc_hosts: true
fqdn: almalinux.lan
chpasswd:
expire: False
users:
- default
package_upgrade: true
```

## user-data of almalinux
```
#cloud-config
hostname: almalinux
manage_etc_hosts: true
chpasswd:
expire: False
users:
- default
package_upgrade: true
```

Later I checked image created for Ubuntu with non FQDN hostname.
In case of **ubuntu**, no `fqdn` key in **user-data** was created by Proxmox. But **hostname was correctly set up**.

## user-data of ubuntu
```
#cloud-config
hostname: ubuntu
manage_etc_hosts: true
chpasswd:
expire: False
users:
- default
package_upgrade: true
```

## Environment details
- Cloud-init version: `/usr/bin/cloud-init 23.1.1-10.el8.alma.1`
- Operating System Distribution: `NAME="AlmaLinux" VERSION="8.9 (Midnight Oncilla)"
`
- Cloud provider, platform or installer type: Proxmox 7.3-4

## cloud-init logs

[cloud-init.zip](https://github.com/canonical/cloud-init/files/13538597/cloud-init.zip)

## Links
Similar [topic](https://forum.proxmox.com/threads/cloud-init-hostname-not-working-as-expected-rhel8-rocky-linux-centos-8.95172/) on Proxmox forum

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.