Chain blueprint step outputs and inputs

Chain blueprint step outputs and inputs

You can use output of one blueprint step as an input of another step. This enables the flow of data and makes it possible to pre-configure complex automated blueprints containing multiple interrelated steps. For example, you may chain output values from a server launch step (i.e. server attribute values) to a configuration step requiring a server attribute value as an input.

Note: If you use a script as a step in a blueprint, you can define the output format of the script as Text or JSON. The subsequent steps can use the text or JSON output as input.

Example workflow

The following example demonstrates how to chain output parameters and input parameters using a simple blueprint workflow. 

Step 1: Create a script

  1.  From the menu bar, click Smart Build.
  2. Click New Script.
  3. Enter the name of the script as JSON Output.
  4. Enter Type (File Ext) as bash and click Next.
  5. Enter the following code in the script source editor and click Next:
    echo "{\"result\": {\"message\":\"success\", \"code\": 200}, \"time\": 300}"
  6. Click Next and click Finish.

Step 2: Create another script

  1. From the menu bar, click Smart Build.
  2. Click New Script.
  3. Enter the name of the script as Second script.
  4. Enter Type (File Ext) as bash and click Next.
  5. Enter a simple script code in the script source editor and click Next.
  6. Click Next and Click Finish.

Step 3: Create a blueprint

  1. From the menu bar, click Smart Build.
  2. Click New Blueprint.
  3. Enter the name of the blueprint as JSON Script Output.

Step 4: Configure global blueprint parameters

  1. Click the Deploy tab.
  2. Under the Runs On tab, click Select Servers and select a machine to run this blueprint.
  3. Under the Blueprint Inputs tab, provide the parameter values as follows: 
    • Type - String
    • Key - bp_input
    • Value - old

Step 5: Configure blueprint steps to chain outputs and inputs

  1. In the left pane, expand My Scripts and drag and drop the script JSON Output as first step in the blueprint.
  2. Under the Runs On tab, click Select Servers and select a machine to run this script step.
  3. Under the Options tab, Select JSON from the Output Format box. The default option is Text.
  4. In the left pane, expand My Scripts and drag and drop the script Second script as second step in the blueprint.
  5. Under the Runs On tab, click Select Servers and select a machine to run this script step.
  6. Under the Inputs tab, Select the Type as String; enter the Key as ResultMessage
  7. Click the tree icon clm-reference-tree-icon.png to define the input value.
  8. Expand JSON Script Output > 1. JSON Output > Machine-name.
  9. Select output and enter result.message and click OK.
  10. Repeat steps 6 to 9. The parameter configuration should look similar to the following:

    parameter-config.png

  11. Under Options tab, click Add in the Before Execution field to add a Velocity Template Language (VTL) expression to run before this step. You can also add a VTL expression to run after this step based on your requirement. 
    Note: You can add VTL expressions corresponding to step outputs of preceding steps in a blueprint.
  12. Select the conditions, input and output expression from the dropdown boxes. The expression is similar to the following:

    vtl-expression-sample.png

  13. Click Validate to verify if the expression is valid. A confirmation message appears if the expression is valid or not.
  14. Click Ok.

    vtl-before-execution.png

  15. Click Save to save the blueprint.

Step 6: Deploy the blueprint

  1. From the menu bar, click Smart Build. Alternatively, you can click Deploy from the Blueprint Designer.
  2. Search the blueprint from the list.
  3. Move the pointer over the blueprint and click Actions > Deploy.
  4. Click Start deployment setup.
  5. Review the Pre-deployment Checklist for your resource location and click Continue.
  6. Click Next. Review the blueprint configuration parameters and click Next.
  7. Enter a profile name and click Save.
  8. Click Deploy.

Step 7: View deployment details

  1. From the menu bar, click Manage. 
  2. In the Deployments page, move the pointer over the deployment name and click Details.
  3. Click Get Deployment Report.
  4. Click the JSON Output step and click the Step Output tab. The step output is provided in the JSON format. 
  5. Click the Second Script step and click the Step Details tab.
    The fields mentioned in the JSON output of the first step are used as input parameters in the second step Second Script.





0 Comments