View Issue Details

IDProjectCategoryView StatusLast Update
0010693Rocky-Linux-9cloud-initpublic2025-09-24 02:06
ReporterTumi Ayoola Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
PlatformAzureOSrockylinux-x86_64OS Version9-base
Summary0010693: Hostname Reverts to `localhost.localdomain` After VM Deployment from Custom Rocky 9 Image
DescriptionI am building a custom Rocky Linux 9 image for use in Azure, and I am encountering an issue with the VM hostname after deployment.
Process
1. I use HashiCorp Packer to build the image starting from the official Rocky Linux 9 Marketplace image (`resf`, `rockylinux-x86_64`, `9-base`).

2. During the build, I install and configure:

   * `cloud-init` (with Azure datasource enabled)
   * `WALinuxAgent`

3. I configure cloud-init with the following files:
/etc/cloud/cloud.cfg.d/90-azure-datasource.cfg

```yaml
datasource_list: [ Azure ]
datasource:
  Azure:
    apply_network_config: true
    set_hostname: true
```

**`/etc/cloud/cloud.cfg.d/99-azure-hostname.cfg`**

```yaml
preserve_hostname: false
manage_etc_hosts: true
```

**`/etc/cloud/cloud.cfg.d/05-logging.cfg`**

```yaml
output: {all: '| tee -a /var/log/cloud-init.log'}
```

4. I update the Azure Linux Agent configuration:

**`/etc/waagent.conf`**

```ini
Provisioning.UseCloudInit=y
Provisioning.Enabled=n
```

5. Before capturing the image, I clean the machine identity:

```bash
cloud-init clean --logs --machine-id
echo -n > /etc/machine-id
rm -f /var/lib/dbus/machine-id
echo -n > /etc/hostname

Expected Behavior

* When creating a VM from this image (via Terraform or Azure Portal), the hostname should match the `computer_name` specified during deployment and remain consistent.

### Observed Behavior

* On boot, the hostname briefly appears correctly (as provided in the deployment).
* After \~1 minute, the hostname reverts to `localhost.localdomain`.
* Reviewing `cloud-init.log` suggests that cloud-init is running but is not applying the Azure-provided hostname as expected.

### Questions

* Is there a known issue in **Rocky Linux 9** cloud-init integration with Azure that causes the hostname to reset to `localhost.localdomain`?
* Are additional configuration steps required in Rocky 9 to ensure the hostname is preserved properly in Azure?

**Environment**

* Rocky Linux 9 (Marketplace image from `resf`)
* Custom image built with HashiCorp Packer
* Published to Azure Compute Gallery
* Deployed using Terraform and Azure Portal
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2025-09-24 02:06 Tumi Ayoola New Issue