Install.py is changing 'hostname' in Ubuntu 18.04

Ok, this one surprised me this morning.

I setup a brand new VPS cloud server with a new provider and used the instructions for running the easy install method with install.py

When everything had successfully installed, I rebooted the host and immediately set out to get things in order so I could configure my default frappe account, setup poorman’s backup, etc.

So, since I had to run the install.py and let it create the default user, I now needed to set a password for that account. So I executed the command:

sudo passwd my_user

and I got the response:

Unable to resolve hostname ubuntu

It still allowed me to set the password, but everytime I used the sudo command I got this strange message. While it has not affected anything yet (because I have not yet run through the startup wizard), I am sure this will cause something to blowup sometime unless I can fix it.

Well, it turns out that Ubuntu 18.04 has changed how it saves hostnames. So even if I go in and edit the /etc/hostname to the correct name, it will reset to whatever the install.py script set it to (which causes errors).

So, not only do you have to set the hostname in:

/etc/hostname

You also have to set it in:

/etc/hosts

And then you are still not done!! You also have to edit another file to keep it from changing on you again after a reboot. To do that you have to do the following:

sudo nano /etc/cloud/cloud.cfg

Then you look for the entry:

preserve_hostname: false

Change the value to “true” and save the file. Afterward, if you do a reboot, the hostname you had set when you bought the server lease will be preserved and the error will no longer get in the way.

This is different than previous versions of Ubuntu and it was pretty frustrating for a while this morning until I stumbled across this link:

How to change the hostname in Ubuntu 18.04

Anyway, I hope this helps someone else to NOT waste a bunch of time chasing the new hostname functions in Ubuntu. :sunglasses:

BKM

2 Likes