Skip to content

Set hostname explicitly in cloud-init for proxy nodes

Krish Moodbidri requested to merge feat-fix-hostname-for-proxy-nodes into main

we've seen the nodename gets overwritten to an appended hash; hence setting it in the user_data.txt 172.20.10.32 ssh-proxy

172.20.10.6 http-proxy-edbc74b

Issue: Cloud-init repeatedly fails to apply the intended hostname:

[   11.513093] cloud-init[785]: util.py[WARNING]: Failed to set the hostname to http-proxy.openstack.internal. (http-proxy)
[   12.423808] cloud-init[869]: util.py[WARNING]: Failed to set the hostname to http-proxy.openstack.internal. (http-proxy)
[   14.037461] cloud-init[869]: util.py[WARNING]: Running module set_hostname (...) failed

Despite passing hostname=http-proxy in our user-data (CI argument), the image’s name tag (e.g. “http-proxy-edbc74b”) persists.

Packer image tagging: During the build, Packer appends a random build ID to the image name for artifact tracking.

Proposed fix: Force a persistent hostname override after cloud-init’s built-in steps

I used hostnamectl instead of hostname because hostnamectl updates the persistent system hostname by modifying the appropriate configuration files, ensuring the change remains after a reboot The --static flag ensures that only the static (persistent) hostname is updated, without affecting the pretty or transient hostnames.

resolves #244 (closed)

Merge request reports

Loading