Prevent cloud-init from Changing Your Hostname on Reboot

This is something that periodically bites me when I'm doing deployments in OVB. Because I'm dealing with cloud instances, cloud-init runs on each reboot and one of the things it does is change the hostname to whatever Nova's metadata says it should be. This behavior is very problematic for something like an undercloud VM because it can change your hostname from, say, undercloud.localdomain to undercloud-test.novalocal when you reboot the VM. Since Nova and Neutron use the hostname as a service identifier that can cause the undercloud to become completely broken until the hostname is changed back.

It's very simple to fix this, but every time it comes up I seem to have trouble finding a resource that just tells me how to do it. I found a couple of posts that discussed the problem but had no solutions, and a few that had very hacky solutions that I didn't want to use. So here's the fix:
echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_hostname.cfg
It's that simple. With that file in place, cloud-init will not mess with the hostname.