You can create custom resources that you can use to build cloud templates using vRealize Orchestrator workflows. In this use case, you add a custom resource that adds an SSH host. You can then include the resource in cloud templates. This procedure also adds an update workflow so that users change the SSH configuration after deployment rather than perform individual day 2 actions.

Custom resources are vRealize Orchestrator or extensibility action objects that you manage through vRealize Automation with the lifecycle actions defined in the custom resource. The cloud template service automatically calls up the appropriate vRealize Orchestrator workflows or extensibility actions when the operation associated with a specific lifecycle action is triggered. You can extend the functionality of the resource type by also selecting vRealize Orchestrator workflows or extensibility actions that can be used as day 2 operations.

This use case uses built-in workflows provided in the vRealize Orchestrator library. It includes prescriptive values or strings to demonstrate how to perform the process. You can modify them to suit your environment.

For reference purposes, this use case uses a project named DevOpsTesting. You can replace the project with one that you already have.

Prerequisites

  • Verify that you configured a vRealize Orchestrator integration. See Configure a vRealize Orchestrator integration in Cloud Assembly.
  • Verify that the workflows that you are using for the create, update, destroy, and day 2 actions exist in vRealize Orchestrator and run successfully from there.
  • In vRealize Orchestrator, locate the resource type used by the workflows. The workflows included in this custom resource must all use the same resource type. In this use case, the resource type is SSH:Host. For more information on resource type validation, see Custom resource types for vRealize Automation Cloud Assembly cloud templates.
  • Verify that you know how to configure and deploy a machine cloud template.

Procedure

  1. Create an SSH host custom resource for adding SSH to a cloud template.
    This step adds the custom resource to the cloud template design canvas as a resource type.
    1. In vRealize Automation Cloud Assembly, select Design > Custom Resources, and click New Custom Resource.
    2. Provide the following values.

      Remember, except for the workflow names, these are sample values.

      Table 1.
      Setting Sample Value
      Name SSH Host - DevOpsTesting Project

      This is the name that appears in the cloud template resource type palette.

      Resource Type Custom.SSHHost

      The resource type must begin Custom. and each resource type must be unique.

      Although the inclusion of Custom. is not validated in the text box, the string is automatically added if you remove it.

      This resource type is added to the design canvas so that you can use it in the cloud template.

    3. To enable this resource type in the cloud template resource type list, verify that Activate option is toggled on.
    4. Select the Scope setting that makes the resource type available to the DevOpsTesting project.
    5. Under Based on, verify that vRO Inventory is selected as the lifecycle action provider.
    6. Select the workflows that define the resource.
      Setting Setting
      Lifecycle Actions - Create Select the Add SSH Host workflow.

      If you have multiple vRealize Orchestrator integrations, select the workflow on the integration instance you use to run these custom resources.

      After select the workflow, the external type drop-down menu becomes available and is automatically set to SSH:Host. An external source type can be used only once if share and once per project. In this use case, you are providing the custom resource for only the DevOpsTesting project. If you had other workflows that require the SSH:Host type, you must create individual custom resources for each project.

      Lifecycle Actions - Update Select the Update SSH Host workflow.
      Lifecycle Actions - Destroy Select the Remove SSH Host workflow.
    7. Review the schema key and type values in the Properties tab so that you understand the workflow inputs so that you can configure the inputs in the cloud template.
      The schema lists the required and optional input values defined in the workflow. The required input values are included in the cloud template YAML.

      In the Add SSH Host workflow, hostname, port, and username are required input values. The other schema properties are not required. You can also use the schema to determine where you want to create bindings to other field values, workflows, or actions. Bindings are not included in this use case.

    8. To finish creating your custom resource, click Create.
  2. Create a cloud template that adds the SSH host when you deploy it.
    1. Select Design > Cloud Templates, and click New from > Blank canvas.
    2. Name the cloud template Machine with SSH Host.
    3. Select the DevOpsTesting project, and click Create.
    4. Add and configure a vSphere machine.
    5. From the custom resource list on the left of the cloud template design page, drag the SSH Host - DevOpsTesting Project resource type onto the canvas.
      Note: You can select the custom resource by either scrolling down and selecting it from the left pane, or searching for it in the Search Resource Types text box. If the custom resource does not appear, click the refresh button next to the Search Resource Types text box.
      A reminder that the resource type is available because it was configured for the project. If you were creating a cloud template for another project, you cannot see the resource type.
    6. On the right, edit the YAML code to add the mandatory input values.
      Add an inputs section in the code so that users can provide the user name and the host name at deployment time. In this example, the port default is 22. In the following example, some of these values are sample data. Your values might be different.
      inputs: 
        hostname:
          type: string
          title: The hostname of the SSH Host
        username:
          type: string
          title: Username
      
    7. In the resources section, add ${input.input-name} code to prompt for the user selection.
      resources:
        Custom_SSHHost_1:
          type: Custom.SSHHost
          properties:
            port: 22
            hostname: '${input.hostname}'
            username: '${input.username}'
      
  3. Deploy the cloud template.
    1. On the cloud template designer page, click Deploy.
    2. Enter the Deployment Name SSH Host Test.
    3. Select the Cloud Template Version and click Next.
    4. Complete the deployment inputs.
    5. Click Deploy.
  4. Monitor the provisioning request on the Deployments tab to ensure that the SSH host is included in the deployment and that the deployment is successful.

What to do next

When your tested cloud template is working, you can then begin using the SSH Host custom resource with other cloud templates.