Automation

Library > Automation

The automation section is where scripts, known as Tasks, can be created. Tasks are individual Bash or Powershell scripts which can be selected to run against Instances at the time they are provisioned from the Instance provisioning wizard. In this section, users can also create execution schedules which are configured time intervals on which automated jobs (such as backups) would be carried out.

Tasks

Role Permissions

The User Role Permission ‘Provisioning: Tasks FULL’ is required to create, edit and delete Tasks.

Common Options

When creating a Task, the required and optional inputs will vary significantly by the Task type. However, there are options which are common to Tasks of all types.

Target Options

When creating a Task, users can select a target to perform the execution. Some Task types allow for any of the three execution targets listed below and some will limit the user to two or just one. The table in the next section lists the available execution targets for each Task type.

  • Resource: A HPE VM Essentials-managed Instance or server is selected to execute the Task

  • Local: The Task is executed by the HPE VM Essentials appliance node

  • Remote: The user specifies a remote box which will execute the Task

Execute Options

  • Continue on Error: When marked, automation stacks including this Task can continue when this Task fails. Additionally, Instances provisioned with this Task as part of its automation stack can be considered provisioned successfully even if this Task has failed

  • Retryable: When marked, this Task can be configured to be retried in the event of failure

  • Retry Count: The maximum number of times the Task will be retried when there is a failure

  • Retry Delay: The length of time (in seconds) HPE VM Essentials will wait to retry the Task

  • Allow Custom Config: When marked, a text area is provided at Task execution time to allow the user to pass extra variables or specify extra configuration. See the next section for an example.

Source Options

Task configuration code may be entered locally or sourced via URL. Changing the SOURCE type will often update the available fields in the Task modal to accommodate the selected sourcing.

  • Local: The Task configuration code is written directly in HPE VM Essentials in a large text area. HPE VM Essentials includes syntax highlighting for easier debugging and script writing

  • URL: For Task configuration that can be source via an outside URL, specify the address in the URL field

Allow Custom Config

When “Allow Custom Config” is marked on a Task, the user is shown a text area for custom configuration when the Task is executed manually from the Tasks List Page. This text area is inside the “Advanced Options” section, which must be expanded in order to reveal the text area. Within the text area, add a JSON map of key-value pairs which can be resolved within your automation scripts. This could be used to pass extra variables that aren’t always needed in the script or for specifying extra configuration.

Example JSON Map:

{"key1": "value1",
"key2": "value2",
"os": "linux",
"foo": "bar"}

When the Task is executed, these extra variables would be resolved where called into the script such as in the following simple BASH script example:

echo "<%=customOptions.os%>"
echo "<%=customOptions.foo%>"

The above example would result in the following output:

linux
bar

Task Types

Available Task Types

Task Type

Task Description

Source Options

Execute Target Options

Configuration Requirements

Role Permissions Requirements

powershell

PowerShell Script

Execute PowerShell Script on the Target Resource

Local, Repository, Url

Remote, Resource, Local

None

Library: Tasks

restart

Restart

Restarts target VM/Host/Container and confirms startup status before executing next task in Workflow

System

Resource

None

Library: Tasks

shellscript

Shell Script

Executes Bash script on the target resource

Local, Repository, Url

Local, Remote, Resource

None

Library: Tasks

Task Management

Adding Tasks

  1. Select Automation from within the Library menu

  2. On the Tasks tab, click the Add button

  3. From the New Task Wizard input a name for the task

  4. Select the type of task from from the type dropdown

  5. Input the appropriate configuration details. These will vary based on the selected Task type.

  6. Once done, click SAVE CHANGES

Tip

When writing a Task config, it’s often necessary to reference HPE VM Essentials variables which pertain to the specific Instance the Task is being run against. HPE VM Essentials includes a pop-out column along the right side of the Add/Edit Task modal which lists available variables. Click and drag the relevant variable into the config area and HPE VM Essentials will automatically fill in the variable call formatted for the currently chosen Task type. See the screenshot below.

Editing Tasks

  1. Select Automation from within the Library menu

  2. Click the pencil icon (✎) on the row of the task you wish to edit

  3. Modify Task as needed

  4. Once done, click SAVE CHANGES

Deleting Tasks

  1. Select Automation from within the Library menu

  2. Click the trash icon (🗑) on the row of the Task you wish to delete

Execute Scheduling

Execute Scheduling creates time schedules for automated jobs, such as backups. Backup Jobs are discussed in greater detail in the Backups section and are configured with an execution schedule to coordinate their run times. This section goes through the process of creating and configuring the scheduling object.

Schedules use CRON expressions, such as 0 23 * * 2 equalling Executes every week on Tuesday at 23:00. CRON expressions can easily be created by clicking the corresponding translation in the create or edit Execution Schedule modal below the Schedule field and selecting a new value.

Note

Execute Schedules CRON expressions should not include seconds or years. The days of the week should be numbered 1-7, beginning with Monday and ending with Sunday. SUN-SAT notation may also be used. For more on writing CRON expressions, many guides are hosted on the Internet including this one. HPE VM Essentials execution schedules support most cron syntax but certain more complex expressions may fail to evaluate and the execute schedule will not save. Additionally, some complex expressions may save and work correctly while the friendly written evaluation below the SCHEDULE field is not interpreted correctly. This is due to an issue with the underlying library used to build this feature and cannot easily be resolved at this time.

NAME

Name of the Execution Schedule

Note

When assigning Execution Schedules, the name value will appear in the selection drop-down. Using a name that makes clear the time interval is often helpful.

DESCRIPTION

Description of the Execution Schedule for reference in the Execution Schedules list