Cloud-Init Service
#What Is Cloud-Init Service?
Cloud-init is a service that allows you to fetch custom user data scripts when provisioning new servers through the Cherry Servers Client Portal or API.
#How to Set Cloud-Init Instructions
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, and there are two means of doing this: shell scripts, and cloud-init directives.
#Shell Scripts
The simplest configuration is to use Shell scripts to send instructions to a newly deployable server, which will be executed when the server boots for the first time.
Please ensure that your Shell script starts with “#!/bin/bash”, otherwise your user data directives will be rejected. Using this line ensures that your script is executed non-interactively with root access right by default.
For example:
#!/bin/bash
yum install -y httpd
apt install -y nginx
#Cloud-Init Directives
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 example:
#cloud-config
packages:
- httpd
- mariadb-server
runcmd:
- systemctl start httpd
- sudo systemctl enable httpd
- [ sh, -c, "chmod 755 /var/tmp" ]
In order to pass these scenarios to Cherry Servers API, they must first be converted into base64 format. To do this on a Linux system, you would do the following for your test.sh and test.yaml files:
#test.sh Files
:# base64 test.sh
IyEvYmluL2Jhc2gKeXVtIGluc3RhbGwgLXkgaHR0cGQKYXB0IGluc3RhbGwgLXkgbmdpbngK
#test.yaml Files
:# base64 test.yaml
I2Nsb3VkLWNvbmZpZwpwYWNrYWdlczogCiAtIGh0dHBkIAogLSBtYXJpYWRiLXNlcnZlcgpydW5j
bWQ6CiAtIHN5c3RlbWN0bCBzdGFydCBodHRwZAogLSBzdWRvIHN5c3RlbWN0bCBlbmFibGUgaHR0
cGQKIC0gWyBzaCwgLWMsICJjaG1vZCA3NTUgL3Zhci90bXAiIF0K
The generated output text must then be fetched via the Cherry Servers API user_data parameter when ordering a new server.
#Important Notices
- Server provisioning will take longer than 3 minutes.
- Linux servers with user_data parameter fetched may 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 the event that the script you used did not run as you expected, please check cloud-init logs, that can be found here:
/var/log/cloud-init.log
and
/var/log/cloud-init-output.log
- User-Data is currently available for Linux systems only.
#Integrations
User-Data is currently supported by our cherrygo GO LANG library, Terraform module, and CherryCTL.
The latest version of the Cherry Servers Terraform module for your OS can be found in our repository: http://downloads.cherryservers.com/other/terraform/
The latest version of the CherryCTL program can be found on GitHub: https://github.com/cherryservers/cherryctl
More detailed instructions are available on our Cherry Servers GitHub account: https://github.com/cherryservers