2

My initial idea is not to disable cloud-init from the ubuntu server 18.04.1 I'm configuring, but I think it will be what I will do if I cannot solve this.

The issue is I'm setting the hostname dynamically from my DHCP server. However although I get systemd-hostname saying the new hostname is set, this is not true as in every reboot it is set back to the former.

I have try to modify the default cloud-init seed to remove the hostname line, but it is the same. Any idea?

# cloud-init clean
# modify user-data removing hostname
# cloud-init init
# reboot

1 Answer 1

1

It appears that you need to set /etc/hostname to localhost in order for the DHCP hostname to be considered. See context_update_kernel_hostname() in hostnamed (https://github.com/systemd/systemd/blob/master/src/hostname/hostnamed.c#L267).

If you've already removed any hostname lines from /var/lib/cloud/seed/nocloud[-net]/user-data then cloud-init shouldn't be messing with the hostname anymore. Make sure you also run sudo cloud-init clean to remove any cached data from cloud-init.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .