How to Use Recipes in the Cloud Control Panel
Recipes are a powerful tool in the ServerMania Cloud control panel which allow you to automate server tasks using step-by-step programmed actions.
In this article, we’ll show you how to use recipes with your ServerMania Cloud server.
Creating A Recipe
Go to your Control Panel > Cloud > Recipes menu. Click the “+” button to add a recipe:
From there, fill in the recipe creation form:
Label -give your recipe a label
Description – provide a short recipe description (optional)
Compatible with – choose if this recipe can be assigned to Unix or Windows virtual servers. For Windows compatible recipe, specify the script type. You can select the following script types:
BAT
VBS
PowerShell v1.0
Click Save.
After that, you’ll be redirected to the recipe details screen where you can add steps to this recipe.
Create Recipe Steps
To create a new recipe step click the “+” button in the upper right corner of the Steps screen:
create a new recipe
In the pop-up window, specify step details as required:
Script – input the recipe code.
Result source – specify the step result source:
Exit Code – an exit code, for example, 0 is the default value returned on success.
To use exit code in the VBS or PowerShell scripts, you have to specify it directly in the script. For example:
VBS
Script:
WScript.Echo “test”
WScript.Quit 95
PowerShell
Script:
get-date -displayhint date
exit 227
STDOUT – standard output.
STDERR – standard error
STDOUT and STDERR – standard output and standard error.
Move the Pass anything else slider to the right if you do not want to specify the pass output value. Otherwise, leave this slider disabled to set the pass values.
Pass values – specify the pass output value, for example, 0.
You cannot specify both pass and fail values for one recipe step. You can specify multiple recipe values. In this case, you have to specify each value from a new line.
On success – the recipe behavior on success:
Proceed – proceed to the next step.
Fail – terminate the recipe and mark it as failed.
Stop– terminate the recipe and mark it as successful.
Go to step – specify the step to proceed to. If you specify the nonexistent step, the recipe will be stopped.
In case you have already specified the recipe pass values, you will get the Fail anything else slider enabled automatically, as you cannot specify both pass and fail values for one recipe step. Move this slider to the left if you want to set fail values (Pass anything else slider will be enabled automatically).
Fail values – specify the pass output value.
On failure – the recipe behavior on failure
Proceed – proceed to the next step.
Fail – terminate the recipe and mark it as failed.
Stop- terminate the recipe and mark it as successful.
Go to step – specify the step to proceed to. If you specify the nonexistent step, the recipe will be stopped.
Press Save.
Running A Recipe
Go back to the recipes page and click the gear icon to run a script on a virtual server:
Example Recipe
Here is an example recipe. It runs on virtual servers for Apache server installation and default web page configuration.
It can be used for the following events:
- VS provisioning (starts Apache server during the VS creation)
- Network rebuild
- Network interface added
Consists of 5 steps. Each step depends on the previous step result.
Step 1
#if echo $OPERATING_SYSTEM_DISTRO |grep rhel ; then if rpm -qa |grep httpd |grep -v grep ; then yum -y update httpd else yum -y install httpd fi #else # exit 1 #fi
Result source: Exit code
Pass values: 0
On success: Proceed
Fail values: Fail anything else
On failure: Fail
Step 2
echo "<p><a href=http://$CP_ADDRESS>OnApp Cloud</a></p>" > /var/www/html/index.html
Result source: Exit code
Pass values: 0
On success: Go to step 5
Fail values: Fail anything else
On failure: Go to step 4
Step 3
service httpd restart
Result source: Exit code
Pass values: 0
On success: Stop
Fail values: Fail anything else
On failure: Fail
Step 4
echo "Can not write to file" > /var/log/recipes.log
Result source: Exit code
Pass values: 0
On success: Stop
Fail values: Fail anything else
On failure: Fail
Step 5
echo “<p><a href=http://$IP_ADDRESS>$HOSTNAME</a></p>” >> /var/www/html/index.html
Result source: Exit code
Pass values: 0
On success: Go to step 3
Fail values: Fail anything else
On failure: Go to step 4
Deleting A Recipe
Go back to the recipes page and click the gear icon to delete a recipe:
Need help managing your cloud server?
Our support team is available 24 hours a day to assist you. Please contact us via ticket or live chat for support.