Cloud-Init and User-Data
User Data is a way to automatically provision your machine with additional software or settings. You can provide a set of commands (ie. 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 datasoure, 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’re creating 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
htop on an Ubuntu instance using Apt after having
upgraded all packages on an Debian/Ubuntu system.
Add the following to the
User Data field to install the
#cloud-config runcmd: - 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 could be achieved with:
#cloud-config package_upgrade: true packages: - screen - htop
Example: cloud-config YAML
Let’s set our locale to en_US.UTF-8 using cloud-config YAML. Add the following YAML in the User Data:
#cloud-config locale: "en_US.UTF-8"
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
curl http://metadata.exoscale.com/latest/meta-data curl http://metadata.exoscale.com/latest/meta-data/public-ipv4
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
Once 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 automatically the above process if the system allows for password based logins.
- Passwords are only provided once back to the user who starts or resets an instance and are not persisted at the orchestration layer