How to Rename our Ubuntu Server


Now that you have create a base install / Master Image of Ubuntu Server, we can create our first clone of that Master Image and use it as our Ansible Master server.

I would recommend against naming either your server or your username as ansible as I have found from experience, this gets confusing AND can cause weird problems. Instead, in this series we will simply call our server: ansible-master.

To do this, firstly, we create a Full Clone of our Master Image, remembering to tick the box to Refresh the MAC Address.

Once the clone is completed, we can power on and login using the credentials you created when building your Master Image.

If you have used something other than Ubuntu Server as your Master Image, changing the server's name may not follow this process - Google is your friend.

As our Master Image was set to have an SSH server installed, I prefer to connect to the new server via SSH. I don't particularly enjoy working directly on any Virtual Machine console.

ssh codereview@192.168.1.169

Change up the username and IP address to match your server. If unsure of the IP address, on the Virtual Machine console, type:

ifconfig

Which will list off the IP addresses your VM has been assigned.

Once on the server, we need to update the server's name in three places.

sudo hostname ansible-master

Then we need to edit the /etc/hosts file:

sudo vi /etc/hosts

Inside that file, change the ubuntu-master (or whatever you called your server in your Master Image) to match your new server name, i.e. ansible-master.

Lastly, we need to edit the /etc/hostname file:

sudo vi /etc/hostname

Changing out whatever is in there to match your new server name, e.g. ansible-master.

Lastly, we give our server a reboot:

sudo reboot now

And we are all done.

Code For This Course

Get the code for this course.

Episodes