Cloud-init is a service that allows you fetch custom user data scripts when provisioning new servers via Client Portal or API.
When ordering a new server through Cherry Servers API you can automate various server configuration tasks by fetching user data directives upon server deployment. Your provided tasks will be executed when your server boots for the first time. There are two ways of doing that - shell scripts and cloud-init directives.
This is the simplest way to send instructions to a newly deployable server that are going to be executed when the server boots for the first time. Your Shell script has to start with "#!/bin/bash" line, otherwise user data directives will be rejected. Your script is then executed non-interactively with root access rights by default.
A simple example:
yum install -y httpd
apt install -y nginx
Cloud-Init directives are also executed when your server boots for the first time, but the syntax is slightly different. Your scenario must start with "#cloud-config" line, otherwise user data directives will be rejected. For further reference we recommend checking cloud-init official documentation: https://cloudinit.readthedocs.io/en/latest/index.html
A simple example:
- systemctl start httpd
- sudo systemctl enable httpd
- [ sh, -c, "chmod 755 /var/tmp" ]
In order to pass these scenarios to Cherry Servers API, they have to be converted into base64 format. On a Linux system you would do the following for your test.sh or test.yaml file:
:# base64 test.sh
:# base64 test.yaml
This output text then has to be fetched via Cherry Servers API user_data parameter when ordering a new server.
Please bear in mind when using user data functionality:
- Server provisioning will take longer than 3 minutes. Linux servers with user_data parameter fetched will take up to 10 minutes, plus any required time for user_data script to complete;
- Additional scripts should be used with responsibly, since misused scripts can disrupt the system;
- In case the script you used did not run as you expected, please check cloud-init logs, that can be found here:
- User-Data is currently available for Linux systems only.
User-Data is currently supported by our cherrygo GO LANG library Terraform module and cherryctl.
Terraform module for your OS can be downloaded here: http://downloads.cherryservers.com/other/terraform/
Cherryctl program for your OS can be downloaded here:
More detailed instructions are available on our cherryservers GITHUB account: https://github.com/cherryservers