Rocky-linux 10 /etc/hosts not updating after applying template

Make your changes to /etc/hosts, and then do:

chattr +i /etc/hosts

it then makes the file immutable to changes. I do this at OVH with my /etc/resolv.conf because they constantly overwrite it despite me trying to get cloudinit to stop doing it.