Creating Command Workflows

You can use command workflows to perform tasks on deployed VMs, virtual services, entire services and managed systems.

You can run a command workflow manually or on a schedule. You can also run a command workflow for a service through a policy or when rejecting a new service request.

Service Portal users may also run a command workflow on a service if you make it available in the Service Portal. Service Portal users don't have access to managed systems, so they can't run command workflows on managed systems.

Examples of tasks that you can perform with a command workflow include:

  • Launching a ticketing system
  • Carrying out a sequence of commands when a policy is triggered
  • Cleaning up components when rejecting a stalled service request
  • Installing applications
  • Making configuration changes to a managed system
  • Executing CLI commands with stored credentials against a managed system

If the task that your command workflow performs requires a notification email, we recommend that you set up the email notification through a workflow step in the command workflow. Although the legacy method of choosing a set of triggers for the workflow is still supported, it's no longer recommended. For more information, see Setting up email notification for command workflows.

In this topic:

Related Knowledge Base articles:

Creating command workflows

Access through:

Configuration menu > Command Workflows

Available to:

Commander Role of Superuser and Enterprise Admin

To create a command workflow:

  1. On the Command Workflows tab, click Add.

    As a shortcut, you can select a workflow in the list and click Copy. This option can save you time because it copies much of the workflow's existing configuration.

  2. In the Command Workflow Configuration dialog, on the Name and Type page, enter a name for the workflow.
  3. Choose an available icon, or click Manage Icons to add an icon.

    Service Portal users see these icons in the list of commands available for a VM. See Managing Icons for Command Workflows below for more details.

  4. From Target Type, choose the types of services or infrastructure that you want the command workflow to be run on:
    • Any Target Type — Select this option if you want to use the command workflow for any type of service or managed system.
    • Application Stack
    • Auto Scaling Group
    • Database
    • Load Balancer
    • Managed System
    • Virtual Service
    • VM
    • No Inventory Target — Select this option if you want to use the command workflow without targeting infrastructure managed by Commander. For example, you could create a command workflow with no inventory target that will be used to update Commander custom attributes with values retrieved from an external server.

    Click Next.

  5. On the Steps page, click Add, select a step to include in the workflow module, and then set its configuration parameters in the Step Details pane.

    When configuring steps, consider the following:

    • By default, steps execute automatically. However, you can set steps to execute only for specific conditions. To make a step conditional, select Step Execution > Execute when conditions are met, then click Edit and define the condition. See Making Workflow Steps Conditional for more details.
    • You can click vars-20x20 in any text field that supports variables to open the Variable Assistant. The Variable Assistant allows you to select variables for the current context and access help for each variable.
    • By default, if a step fails when a workflow is run, no re-attempt to execute it is made. If you want a workflow to re-attempt to execute a step if it fails, select the step, then click Add > Retry Selected Step. For more information, see Adding Retry Steps to Workflows.

      Limitation: When you add a Send Approval Email step to a command workflow, request comments may not appear on the approval landing page.

    For details on built-in steps, see Workflow Steps Reference. For details on plug-in steps, see the readme files included with the plug-in step JAR files added to your system at <Commander_install_directory>\tomcat\wfplugins\. See Using Plug-In Workflow Steps.

  6. Continue to add steps to the workflow module, as appropriate. Click Next when you're done.

    To change the order of a step, use the up and down arrows, or click Delete to remove it.

  7. On the Permissions page, choose the users and groups that will have access to this workflow.

    If you don't want the global workflow to apply to all users and groups, you can override the global workflow by creating additional command workflows and assigning them to specific users and groups.

  8. On the Options page, do any of the following, then click Next:
    • If this workflow is to be made available to Service Portal users, enable Display in Service Portal.

      Service Portal users must have the Run Command Workflows permission.

    • If you want to help prevent users from running the workflow multiple times, enable Prompt for Confirmation.

      You can enter a custom confirmation message to inform end users about the purpose of the workflow, as well as its potential impact. Line breaks are preserved, but other formatting is not applied to the message.

      If you don't enter a message, the default message "Are you sure you want to run the command "<workflow name>"?" is displayed.

  9. On the Summary page, enter details about the workflow in the Description of Changes field.

    For example, you might describe the purpose of a new workflow or, if you are editing an existing workflow, the nature of the changes that you made.

  10. Review the workflow's configuration details, and click Finish when you're done.

    To set up who is to be notified by email when command workflow actions occur, see Setting up email notification for command workflows.

Managing icons for command workflows

Access through:

Configuration menu > Command Workflows

Available to:

Commander Role of Superuser, Enterprise Admin

You can assign icons to command workflows. Portal users see these icons in the list of commands available for a service. Commander includes several icons by default, but you can add your own as well as delete icons from the list.

  1. On the Command Workflows page, click Manage Icons.

    You can also manage icons from within the Command Workflow Configuration wizard.

  2. In the Manage Workflow Icons dialog, do the following:
    • To add an icon, click Add, navigate to the icon you want to add, select it, and click Open.

      Files must be no more than 1 MB in size and must be .gif, .jpeg, or .png files. They should be 36 x 36 pixels for best results.

    • To delete an icon, select the icon in the list and click Delete.

      If the selected icon is assigned to one or more workflows, a message informs you that these workflows will revert to the default icon.

  3. Click Close.

Running and scheduling command workflows

You can manually run a configured command workflow at any time.

Or

You can schedule a command workflow to run at a specific time either once or on a recurring basis. Scheduling a workflow task is useful because it allows you to take advantage of maintenance windows, for example.

Running command workflow for infrastructure targets

Access through:

Right-click a service or a managed system in the directory tree

Available to:

Administrator Access Rights

To run a workflow configured for a specific infrastructure target type:

  1. Select the service or managed system, right-click and select Run Workflow.
  2. In the Select A Workflow dialog, select a command workflow from the list.

    All command workflows for the selected service type or managed system are displayed.

  3. Choose one of the following options:
    • Run the workflow immediately:
      1. Click Run.
      2. If the workflow was configured to prompt the user before running, a confirmation dialog appears; click Yes.

        The workflow steps start.

    • Run the workflow on a schedule:
      1. Click Schedule.
      2. In the Configure Scheduled Task wizard, enter the frequency, date and time you want the workflow to run, then click Next.
      3. Review the configured schedule, and click Finish when you're done.

        To edit the workflow schedule later, click Tools > Scheduled Tasks. For more information, see Scheduling Tasks.

    To view the status of the workflow, click the Workflows tab at the bottom of the Commander window. When a workflow starts, this tab turns orange. See Viewing the Status of Workflows for more information.

Running command workflows for no infrastructure targets

Access through:

Configuration menu > Command Workflows

Available to:

Commander Role of Superuser and Enterprise Admin

To run a workflow configured for no infrastructure target:

  1. On the Command Workflows tab, select a command workflow that is configured with a No Inventory Target.

    The Schedule > Run Now and Schedule > Schedule commands aren't available for command workflows with target types other than No Inventory Target.

  2. Choose one of the following options:
    • Run the workflow immediately:
      1. Click Run.
      2. If the workflow was configured to prompt the user before running, a confirmation dialog appears; click Yes.

        The workflow steps start.

        To view the status of the workflow, click the Workflows tab at the bottom of the Commander window. When a workflow starts, this tab turns orange. See Viewing the Status of Workflows for more information.

    • Run the workflow on a schedule:
      1. Click Schedule.
      2. In the Configure Scheduled Task wizard, enter the frequency, date and time you want the workflow to run, then click Next.
      3. Review the configured schedule, and click Finish when you're done.

        To edit the workflow schedule later, click Tools > Scheduled Tasks. For more information, see Scheduling Tasks.

Deleting command workflows

Access through:

Configuration menu > Command Workflows

Available to:

Commander Role of Superuser and Enterprise Admin

At any time, you can remove a workflow from Commander. After you have removed a workflow, all settings associated with the workflow, including approvers and actors, emails, scripts, and any deployment information, are no longer available. To use those settings again, you must associate them with another workflow.

  1. Select the workflow from the displayed list.
  2. Click Delete and confirm the deletion.

Setting up email notification for command workflows

Commander provides two methods for setting up email notification for command workflows.

If you set up email notification through a workflow step, it is recommended that you disable any legacy email notification that may have been configured through Configuration > Command Workflows > Notifications tab.

Configuring email notification within a command workflow

In the following example, the command workflow uses two steps to backup a VM, then uses a step to send an email to notify the VM's primary owner that the VM has been backed up.

For more information on how to configure workflow steps that send emails, see Workflow steps that send an email.

Email notification within a command workflow

Formatting in the email body

The <a> tag is automatically added to links in emails (only the http protocol is supported). For example, if the value of a custom attribute is a link, the value will be formatted as a link in the email.

If you don't use HTML markup in the email body, the body is assumed to be plain text; <br> and <p> tags are automatically added for new lines.

If you add HTML markup to the email body, however, no additional tags are added.

Clicking vars-20x20 in any text field that supports variables opens the Variable Assistant, which allows you to select variables for the current context and provides help for each variable.

Setting up email notification with the legacy method

Access through:

Configuration menu > Command Workflows > Notifications tab

Available to:

Commander Role of Superuser and Enterprise Admin

  1. In the For Each Command Workflow pane, choose the type of notification to be sent to the user who initiated the workflow and to the component owner. Choose from the following menu options:
    • None: no notification email is sent
    • Done: a notification email is sent when a service request is completed or rejected
    • Basic: a notification email is sent only when a workflow is completed or skipped
    • All: a notification email is sent when any change occurs in a workflow
  2. Click Save.
  3. In the For All Command Workflows pane, click Add.
  4. In the Manage Command Workflow Notifications dialog, enter the user account to whom the email is to be sent.
  5. Click ellipses and the account information is displayed in the dialog.
  6. Click OK and the user account is displayed.
  7. Repeat for as many user accounts as is required.
  8. To cancel email notification for a user, click Delete, then click OK to delete the user account.

    Only the email notification is canceled, not the user account itself.