/etc/hosts file according to the /etc/cloud/templates/hosts.${os_type}.tmpl template and overwrites the original /etc/hosts file of the instance involved. Hence, after you manually modify the internal /etc/hosts configuration of the instance and restart it, the /etc/hosts configuration goes back to the original default configuration./etc/hosts configuration will not be overwritten.
For instance created before September 2018, follow the steps below for modification.- update_etc_hosts in the /etc/cloud/cloud.cfg configuration file to - ['update-etc-hosts', 'once-per-instance']:sed -i "/update_etc_hosts/c \\ - ['update_etc_hosts', 'once-per-instance']" /etc/cloud/cloud.cfg
config_update_etc_hosts file under the /var/lib/cloud/instance/sem/ path:touch /var/lib/cloud/instance/sem/config_update_etc_hosts
hosts template file pathhosts template file:cat /etc/hosts
hosts template file is as shown in the following figure:

hosts template file127.0.0.1 test test as an example, you can modify the hosts template and /etc/hosts file as needed.hosts template file:vim /etc/cloud/templates/hosts.redhat.tmpl
127.0.0.1 test test
/etc/hosts file/etc/hosts file:vim /etc/hosts
127.0.0.1 test test
Feedback