Creating a Custom Task

Cisco Intersight

Audience
Public
Product
FlashStack
Source Type
Documentation

When the built-in system tasks do not perform a specific action that you need to complete, you are able to build a custom task that will utilize one of the four Executors to perform a custom action. To create a custom task, you must define some basic details, define task inputs and outputs to be passed to the Executors, and define some overall task-level inputs & outputs that can be used.

When creating a custom task, the general properties that can be set are the following:

Organization - Name of the Intersight organization that the task will be created in

Task Name - User-friendly name of the task

Description - A description of the task

Retry Count - The number of times to try a task before being marked as failed

Retry Delay - The delay (in seconds) before trying a task again

Timeout - The timeout value (in seconds) that a task is considered as timed out

Set Tags - Set a tag for the task within Intersight (key:value pair)

Enable Rollback Task - Enable to rollback a task and choose an appropriate task from the drop-down list (requires workflow inputs and mappings)

Executor Inputs

For each Executor to be used within a task, these are the available inputs per Executor type:

Ansible Playbook - Playbook Path, Host Inventory, Command Timeout, Command Line Arguments

PowerShell Script - Script, Timeout, and Response Parser

SSH Command - SSH Command, Command Timeout, Expected Exit Codes, and Response Parser

API Request - Method, URL, Headers, Cookies, Response Type, Body, and Response Parser

Executor Outputs

For each Executor to be used within a task, these are the available outputs per Executor type:

Ansible Playbook - Exit Code, Execution Summary, Execution Log Path, and Outcomes (custom execution status and status message)

PowerShell Script - Exit Code, Execution Summary, Execution Log Path, and Outcomes (custom execution status and status message)

SSH Command - Exit Code, Command Output, Command Execution Error, Extracted Parameters, and Outcomes (custom execution status and status message)

API Request - Headers, Cookies, Status Code, Status Message, Parameters, and Outcomes (custom execution status and status message)

Executor Outcomes

When any Executor is used within a workflow, we also have the ability to define an “Outcome”. An outcome is the combination of a condition and task status. It is possible to use extracted values from the API response to determine the task status, then set the status with an appropriate message, when the conditions match.

One or more outcomes can be specified, and the outcomes are then evaluated in the specified order. When the first outcome condition that matches is evaluated, that outcome sets the task status and message. If none of the outcome conditions match, the task shall be marked as successful.

The possible outcomes of a task are as follows:

  • Success—Marks the API execution as Success if the condition matches
  • Skip to Success—Stops further API executions of the task and marks the task as successful when the condition matches
  • Status—Retains a task as work in progress, only updating the status
  • Error—Marks the API execution as Failed if the condition matches. Task retry will be attempted if the task has any retries left
  • Terminal error—Marks the API execution as Failed if the condition matches. This marks a non-recoverable error and no retries are attempted (NOTE: If the task status is Terminal Error, there are no retries for that task.)
  • Skip Task Execution—Skips execution of task if the condition matches in the API. This will skip execution of all the subsequent APIs in the task

Task Level Input

Within a custom task, there are many values that can be set for the input at the task level:

Display Name - User-friendly name of the task used in the task list

Reference Name - Used for referring to this task input for reuse

Description - Detailed description of the input

Value Restrictions - Sets the input as Required or Collection/Multiple values

Type - The data type for a primitive data type. For example, this could be string, integers, enumerations, JSON, specific target devices, and more complex data types.

Depending on the data type, additional options can be set for this task input, including Enum Lists, minimum and maximum range, Regex match for string values, Object Selector (radio button), Intersight API Reference, selector attribute (for filtering), and if the value is secure (values of these properties are encrypted and stored in Cisco Intersight).