Learn how to reconfigure cloud-init so that you can modify your instance’s hostname.
With the cloud-init module, you can configure your Public Cloud instance when you create it, and each time you reboot it. Consequently, if you wish to reconfigure your hostname because of an error when creating your instance or to reconfigure your email server, you will need to disable the Cloud-init module. This will configure the hostname so that it is not re-established.
This tutorial is designed to help you as much as possible with common tasks. If you are having difficulty performing these actions, please contact a specialized service provider. OVHcloud cannot provide you with technical support in this regard.
NOTE: This guide is for instances based on Linux distributions only.
Requirements
- An OVHcloud Public Cloud instance
- SSH access (sudo) to the instance
Instructions
Disable the cloud-init module
For this guide, we will use the file editor vi because it is present by default on Linux distributions. You can use the editor of your choice.
Basic use of vi:
- Press i to enter text insertion mode.
- Press Esc (Esc) to exit insertion mode.
- Type: wq then Enter to save and exit.
- Type: q! then Enter to exit without saving.
To disable cloud-init, you will need to start by modifying the configuration file:
Simply add the following two lines, or modify them if they already exist:
Modify the hostname
The first step involves modifying the hostname. In this example, we will change the hostname to webserver. You can edit as it suits your preference:
Add or replace content by:
Next, you will need to modify the /etc/hosts file:
Add or replace content by:
You will then need to reboot the instance:
After the reboot, the hostname modifications will be properly applied:
Go further
For more information and tutorials, please see our other Public Cloud support guides or explore the guides for other OVHcloud products and services.