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:
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