Create and Manage Recipes

A recipe is a plugin mechanism used for adding new functionalities to the OnApp cloud. Each recipe is a set of instructions that trigger events at certain stages during the execution of certain services/event in the cloud. Essentially, recipes allow inputting code into virtual servers, appliances or the Control Panel server. This enables administrators to use recipes for configuring the server or report on it, thus providing advanced customization options in a standard environment. In this document you can find information on how to create and manage recipes. 

You can create and use recipes for Unix (Linux and FreeBSD) and Windows virtual servers, smart servers, baremetal servers, virtual server templates, Compute zones and the control panel server. For details, refer to the relevant sections of the Admin guide:

Create Recipe



Adding a recipe consists of two stages:

  1. Creating a recipe
  2. Creating a recipe step

Create Recipe

To create a recipe:

  1. Go to your Control Panel's Recipes menu.
  2. Click the "+" button.
  3. Fill in the recipe creation form:

    Properties

    Label -give your recipe a label

    Description - provide a short recipe description (optional)

    Unix compatible - move this slider to the right to use this recipe for Unix virtual servers.

    Windows compatible - move this slider to the right to use this recipe for Windows virtual servers.

    For Windows compatible recipe, specify the script type. You can select the following script types:

    • BAT
    • VBS
    • PowerShell v1.0

  4. Click Save.

After that, you'll be redirected to the recipe details screen where you can add steps to this recipe.

Create Steps

To create a new recipe step:

  1. Click the "+" button in the upper right corner of the Steps screen.

  2. 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.

  3. Press Save.

    Drag and drop steps to change their order. To do so:

    1. Select the required step and hold it down with the left mouse button.
    2. Drag the recipe up to the required position and release the mouse button to drop it.

Assign Recipe to Multiple Servers



You can assign recipe to several virtual or smart servers at once. To do so:

  1. Go to your Control Panel’s Recipes menu.
  2. On the screen that appears, you’ll see the list of all recipes in the cloud.
  3. Click the Actions icon next to required recipe and click the Run Recipe on Vs(s) button.
  4. On the screen that appear, tick the check boxes next to the servers you want to assign the recipe to.
  5. Click the Run on Selected button to confirm the selection.

Assigning several recipes to the same server may lead to simultaneous recipe implementation and performance issues.

  • When assigning one recipe to several servers via API, there is possibility to run the recipe incompatible with the server type (Unix recipe on Windows servers or vice versa). In this case the transaction will be scheduled and completed, but the recipe will not do anything.
  • Note that a VS related recipe is always executed first.

    Example:

    1.You have two recipes, one assigned to a template and another assigned to a VS
    2.You assign both of them to a desired event
    3.After the VS is built, the VS related recipe is run first
    4.Next, the template recipe is run
    This execution order is also relevant when the VS related recipe and template recipe are both assigned to the same event.

Edit Recipe



To adjust recipe details:

  1. Go to your Control Panel's Recipes menu.
  2. Click the label of a recipe you want to edit, then click the Edit icon. You can edit the following recipe details:

    Label - recipe label

    Description - recipe description

    Compatible with - click the appropriate button (Unix or Windows)  to use this recipe for Unix or Windows virtual servers

  3. Click the Save button to save your changes.

To edit recipe step, click the edit icon next to the required step, then change its details as required. Refer to the Edit Recipe Step section below for details.


Edit Recipe Step



To edit recipe steps:

  1. Go to your Control Panel's Recipes menu.
  2. Click the Actions icon next to the recipe you want to change, then click the Edit button.
  3. On the screen that appears, you'll see the list of recipe steps. Click the Edit icon next to the step you want to edit.
  4. In the pop-up window, edit the 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 thiscaseyou 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 set fail values (Pass anything else slider will be enabled automatically).

    Fail values - specify the pass output value.

    On failure - the recipe behaviour 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.
  5. Press Save.

    Drag and drop steps to change their order. To do so:

    1. Select the required step and hold it down with the left mouse button.
    2. Drag the recipe up to the required position and release the mouse button to drop it.

Delete Recipe



To delete a recipe:

  1. Go to your Control Panel’s Recipes menu.
  2. Click the Delete icon next to the recipe you want to remove.
  3. Confirm the deletion.