Step 1
Set the host name on NMTUI tool like following
nmtui
set host name
then save and exit
Step 2
add the following line in last line of /etc/sysctl.conf
vi /etc/sysctl.conf
kernel.hostname = hostname.example.com
then save and exit the editor and run the following command
sysctl -p
Step 3
now add the following line that mentioned below in the following file last line /etc/cloud/cloud.cfg
vi /etc/cloud/cloud.cfg
preserve_hostname: true
save and exit
then reboot and try again.
Set the host name on NMTUI tool like following
nmtui
set host name
then save and exit
Step 2
add the following line in last line of /etc/sysctl.conf
vi /etc/sysctl.conf
kernel.hostname = hostname.example.com
then save and exit the editor and run the following command
sysctl -p
Step 3
now add the following line that mentioned below in the following file last line /etc/cloud/cloud.cfg
vi /etc/cloud/cloud.cfg
preserve_hostname: true
save and exit
then reboot and try again.