Cloud-Init and User-Data
User data is a way to automatically provision your instance with additional software or settings. You can provide a set of commands (a script) or enter cloud-config information as YAML. It is important to understand that the User Data provided will be used only when the machine is created.
Cloud Init Datasources
Historically, Exoscale templates used the
Cloudstack cloud-init datasource.
Since Cloud Init version
19.3, Exoscale has its own datasource.
Although the new Exoscale datasource is backwards-compatible with the Cloudstack datasource, new features such as managed private networks require using the Exoscale datasource. We recommend using the Exoscale datasource for all installations.
Adding user data
When you create a new instance, the wizard lets you enter user data at the bottom of the form.
You can find everything that can be done with user data and Cloud-Init in the documentation
In this example, we install
htop on an Ubuntu instance using Apt
upgraded all packages on an Debian/Ubuntu system.
Add the following to the
User Data field to install the
- apt-get --yes upgrade
- apt-get --yes install screen htop
Note: Cloud-Init has pre-built directives for many items. Therefore, the previous scripts launched as command lines can be achieved with:
Example: Cloud-Config YAML
We will set our locale to en_US.UTF-8 using cloud-config YAML. Add the following YAML in the user data:
Example: Installing Wordpress
See our Wordpress tutorial.
Querying the User Data and Meta Data from the Instance
User Data and
Meta Data can be retrieved from an instance to
integrate in scripts for example or configuration management tools.
This information is published on the Link Local Address
169.254.169.254 which is private between the hypervisor and the
- User Data (the cloud-config contents)
- Meta Data, such as instance size or IP address
The list of available metadata is:
|The zone - datacenter in which the instance is running
|Returns “Exoscale Compute Platform” if running on Exoscale
|The unique identifier or UUID for the instance
|The name of the instance as set during the add instance phase
|The primary network IP address of the instance
|The public IP address of the instance
|The associated SSH public key associated to the instance
|The size of the instance
Adding Password Management to Your Templates
Exoscale provides an optional password reset feature that allows users to set a temporary admin or root password as well as reset the existing admin or root password from the Exoscale Portal.
This password is provided to an instance via the Link Local Address 169.254.169.254 on port 8080:
curl --header "DomU_Request: send_my_password" http://169.254.169.254:8080
After the password is retrieved and changed on the running instance, issue a command to indicate that the password was saved and that it can be deleted:
curl --header "DomU_Request: saved_password" http://169.254.169.254:8080
- Linux-based distributions with a standard Cloud-Init implementation will follow the process outlined above automatically if the system allows for password-based logins.
- Passwords are only provided one time back to the user who starts or resets an instance and are not persisted at the orchestration layer.