# Task Configuration

## Ansible Playbook

![ansible](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-FCAE649B-4E95-4F5B-A897-78C6A01F895D-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **ANSIBLE REPO:** Select existing Ansible Integration
- **GIT REF:** Specify tag or branch (Option, blank assumes default)
- **PLAYBOOK:** Name of playbook to execute, both `playbook` and `playbook.yml` format supported
- **TAGS:** Enter comma separated tags to filter executed tasks by (ie `--tags`)
- **SKIP TAGS:** Enter comma separated tags to run the playbook without matching tagged tasks (ie `--skip-tags`)

IMPORTANT

Using different Git Refs for multiple Ansible Tasks in same Workflow is not supported. Git Refs can vary between Workflows, but Tasks in each Workflow must use the same Git Ref.

## Ansible Tower Job

![ansibletower](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-AF431C26-FA58-4140-8DAA-09CCA119F769-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **TOWER INTEGRATION:** Select an existing Ansible Tower integration
- **INVENTORY:** Select an existing Inventory, when bootstrapping an Instance, HPE Morpheus Enterprise will add the Instance to the Inventory
- **GROUP:** Enter a group name, when bootstrapping an Instance, HPE Morpheus Enterprise will add the Instance to the Group if it exists. If it does not exist, HPE Morpheus Enterprise will create the Group
- **JOB TEMPLATE:** Select an existing job template to associate with the Task
- **SCM OVERRIDE:** If needed, specify an SCM branch other than that specified on the template
- **EXECUTE MODE:** Select Limit to Instance (template is executed only on Instance provisioned), Limit to Group (template is executed on all hosts in the Group), Run for all (template is executed on all hosts in the Inventory), or Skip Execution (to skip execution of the template on the Instance provisioned)

## Chef bootstrap

![chef](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-531590A7-AFBE-40A7-BBBF-D4E7EB32974A-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **CHEF SERVER:** Select existing Chef integration
- **ENVIRONMENT:** Populate Chef environment, or leave as `_default`
- **RUN LIST:** Enter Run List, eg `role[web]`
- **DATA BAG KEY:** Enter data bag key (will be masked upon save)
- **DATA BAG KEY PATH:** Enter data bag key path, eg `/etc/chef/databag_secret`
- **NODE NAME:** Defaults to Instance name, configurable
- **NODE ATTRIBUTES:** Specify attributes inside the `{}`

## Conditional Workflow

![../../_images/conditional.svg](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-C6A92829-120A-43A5-AAFA-221E3A1C89EF-high.svg)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **LABELS:** A comma separated list of Labels for organizational purposes. See elsewhere in HPE Morpheus Enterprise docs for additional details on utilizing Labels
- **CONDITIONAL (JS):** JavaScript logic which determines the Operational Workflow which is ultimately run. If it resolves to `true`, the “If” Workflow is run and if it resolves to `false` the “Else” Workflow is run
- **IF OPERATIONAL WORKFLOW:** Set the Operational Workflow which should be run if the JavaScript conditional resolves to `true`
- **ELSE OPERATIONAL WORKFLOW:** Set the Operational Workflow which should be run if the JavaScript conditional resolves to `false`

## Groovy script

![groovy](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-DA7C204B-DFAC-493A-A877-21B026F00D4D-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **CONTENT:** Contents of the Groovy script if not sourcing it from a repository

## Email

![email](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-9C895BAB-4D33-430F-8250-668229AB3E8A-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **SOURCE:** Choose local to draft or paste the email directly into the Task. Choose Repository or URL to bring in a template from a Git repository or another outside source
- **EMAIL ADDRESS:** Email addresses can be entered literally or HPE Morpheus Enterprise automation variables can be injected, such as `<%=instance.createdByEmail%>`
- **SUBJECT:** The subject line of the email, HPE Morpheus Enterprise automation variables can be injected into the subject field
- **CONTENT:** The body of the email is HTML. HPE Morpheus Enterprise automation variables can be injected into the email body when needed
- **SKIP WRAPPED EMAIL TEMPLATE:** The HPE Morpheus Enterprise-styled email template is ignored and only HTML in the Content field is used

TIP

To whitelabel email sent from Tasks, select SKIP WRAPPED EMAIL TEMPLATE and use an HTML template with your own CSS styling

## HTTP (API)

![http](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-3D6C1D43-48AE-4C22-AB38-7FF3748A8812-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **URL:** An HTTP or HTTPS URL as the HTTP Task target
- **HTTP METHOD:** GET (default), POST, PUT, PATCH, HEAD, or DELETE
- **AUTH USER:** Username for username/password authentication
- **PASSWORD:** Password for username/password authentication
- **BODY:** Request Body
- **HTTP HEADERS:** Enter requests headers, examples below:

|  |  |
| --- | --- |
| Authorization | Bearer token |
| Content‐Type | application/json |

- **IGNORE SSL ERRORS:** Mark when making REST calls to systems without a trusted SSL certificate

## Javascript

![javascript](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-20848F50-8905-4E2C-B84A-2964DB407179-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **SCRIPT:** Javascript contents to execute

## jRuby Script

![jruby](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-6DDC7639-A017-4555-A527-0F3DD5216833-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **CONTENT:** Contents of the jRuby script is entered here if it’s not being called in from an outside source

## Library Script

![libraryscript](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-C1C0F695-54E0-43B9-90F3-A1112041085D-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **SCRIPT:** Search for an existing script in the typeahead field

## Library Template

![template](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-296B3993-FE5F-4AB8-B8AE-71D293861775-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **TEMPLATE:** Search for an existing template in the typeahead field

## Nested Workflow

![../../_images/nestedworkflow.svg](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-949F99E1-949C-499A-980C-1AB5753BA11D-high.svg)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **OPERATIONAL WORKFLOW:** The Workflow to be embedded as a Task for reference inside other Workflows

## Powershell Script

![powershell](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-69279397-D83C-4B50-9330-CA25F54BE9B0-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **VERSION:** Select the version of Powershell this Task should run in. Powershell 5 is the default selection, Powershell 6 or 7 must be installed on the target to select those versions
- **ELEVATED SHELL:** Run script with administrator privileges
- **IP ADDRESS:** IP address of the PowerShell Task target
- **PORT:** SSH port for PowerShell Task target (5985 default)
- **USERNAME:** Username for PowerShell Task target
- **PASSWORD:** Password for PowerShell Task target
- **Content:** Enter script to execute if not calling the script in from an outside source

NOTE

Setting the execution target to local requires Powershell to be installed on the HPE Morpheus Enterprise appliance box(es). [Microsoft Documentation](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.2) contains installation instructions for all major Linux distributions and versions.

## Puppet Agent Install

![puppet](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-D625B993-30CE-4020-ACA7-B098CF811E3F-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **PUPPET MASTER:** Select Puppet Master from an existing Puppet integration
- **PUPPET NODE NAME:** Enter Puppet node name. Variables supported eg. `<%= instance.name %>`
- **PUPPET ENVIRONMENT:** Enter Puppet environment, eg. `production`

## Python Script

![python](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-AB6EBB6F-6FB7-48D7-A2F6-EB4F4012B5A8-high.png)

IMPORTANT

Python Tasks use virtual environments. For this reason, `virtualenv` must be installed on your appliances in order to work with Python Tasks. See the information below for more detailed steps to install `virtualenv` on your HPE Morpheus Enterprise appliance node(s).

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **CONTENT:** Python script to execute is entered here if not pulled in from an outside repository
- **COMMAND ARGUMENTS:** Optional arguments passed into the Python script. Variables supported eg. `<%= instance.name %>`
- **ADDITIONAL PACKAGES:** Additional packages to be installed after `requirements.txt` (if detected). Expected format for additional packages: ‘packageName==x.x.x packageName2==x.x.x’, the version must be specified
- **PYTHON BINARY:** Optional binary to override the default Python binary

NOTE

When troubleshooting errors in Python scripts using line numbers reported in HPE Morpheus Enterprise UI (such as in Task execution histories), you must subtract four line numbers to arrive at the correct line in the Python document. This is because HPE Morpheus Enterprise injects four lines at execution time to add HPE Morpheus Enterprise environment variables.

**Enterprise Proxy Considerations**

Additional considerations must be made in enterprise proxy environments where Python Tasks are run with additional package download requirements. These additional packages are downloaded using `pip` and may not obey global HPE Morpheus Enterprise proxy rules. To deal with this, create or edit the pip configuration file at `/etc/pip.conf`. Your configuration should include something like the following:

```
```
[global]  
proxy = http://some-proxy-ip.com:8087
```
```

For more information, review the Pip documentation on using proxy servers [here](https://pip.pypa.io/en/stable/user_guide/#using-a-proxy-server).

**CentOS 7 / Python 2.7 (RHEL system Python)**

With a fresh install of HPE Morpheus Enterprise on a default build of CentOS 7, Python Tasks will not function due to the missing requirement of `virtualenv`.

If you attempt to run a python task, you will get an error similar to the following:

```
```
Task Execution Failed on Attempt 1  
sudo: /tmp/py-8ae51ebf-749c-4354-b6e4-11ce541afad5/bin/python: command not found
```
```

In order to run HPE Morpheus Enterprise Python Tasks in CentOS 7, install `virtualenv`: `yum install python-virtualenv`

If you require `python3`, you can specify the binary to be used while building the virtual environment. In a default install, do the following: `yum install python3`. Then, in your HPE Morpheus Enterprise Python Task, specify the binary in the PYTHON BINARY field as “/bin/python3”. This will build a virtual environment in `/tmp` using the `python3` binary, which is equivalent to making a virtual environment like so: `virtualenv ~/venv -p /bin/python3`.

If you wish to install additional Python packages into the virtual environment, put them in `pip` format and space-separated into the ADDITIONAL PACKAGES field on the Python Task. Use the help text below the field to ensure correct formatting.

**CentOS 8 and Python**

In CentOS 8, Python is not installed by default. There is a `platform-python` but that should not be used for anything in userland. The error message with a default install of CentOS 8 will be similar to this:

```
```
Task Execution Failed on Attempt 1  
sudo: /tmp/py-cffc9a8f-c40d-451d-956e-d6e9185ade33/bin/python: command not found
```
```

The default `virtualenv` for CentOS 8 is the python3 variety, for HPE Morpheus Enterprise to use Python Tasks, do the following: `yum install python3-virtualenv`

If Python2 is required, do the following: `yum install python2` and specify `/bin/python2` as the PYTHON BINARY in your HPE Morpheus Enterprise Task.

This will build a `virtualenv` in `/tmp` using the `python2` binary, which is equivalent to making a `virtualenv` like so: `virtualenv ~/venv -p /bin/python2`

If you wish to install additional Python packages into the virtual environment, put them in `pip` format and space-separated into the ADDITIONAL PACKAGES field on the Python Task. Use the help text below the field to ensure correct formatting.

## Restart

![restart](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-12DFE21D-BC68-4969-B496-340CA3E40690-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references

## Shell Script

![shellscript](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-66BC263C-CF8F-4199-B05B-99D786BF9288-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **SUDO:** Mark the box to run the script as `sudo`
- **CONTENT:** Script to execute is entered here if not pulled in from an outside repository

TIP

When the EXECUTE TARGET option is set to “Local” (in other words, the Task is run on the appliance itself), two additional fields are revealed: GIT REPO and GIT REF. Use GIT REPO to set the PWD shell variable (identifies the current working directory) to the locally cached repository (ex. /var/opt/morpheus-node/morpheus-local/repo/git/76fecffdf1fe96516e90becdab9de) and GIT REF to identify the Git branch the Task should be run from if the default (typically main or master) shouldn’t be used. If these options are not set, the working folder will be /opt/morpheus/lib/tomcat/temp which would not allow scripts to reference file paths relative to the repository (if needed).

## vRealize Orchestrator Workflow

![vro](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-ABE75AA7-6B9F-46FE-9A67-D463924B577D-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **RESULT TYPE:** Single Value, Key/Value Pairs, or JSON
- **vRO INTEGRATION:** Select an existing vRO integration
- **WORKFLOW:** Select a vRO workflow from the list synced from the selected integration
- **PARAMETER BODY (JSON):**

## Write Attributes

![wa](https://support.hpe.com/hpesc/public/api/document/sd00007621en_us/GUID-C48074E2-3DB2-4459-98D0-AC5282256582-high.png)

- **NAME:** Name of the Task
- **CODE:** Unique code name for API, CLI, and variable references
- **ATTRIBUTES:** A JSON map of arbitrary values to write to the attributes property of the target resource

TIP

This is often useful for storing values from one phase of a Provisioning Workflow for access in another phase. See the video demo below for a complete example.

There are a number of ways that a JSON payload can be statically drafted within a Write Attributes Task or called into the Task as a result from a prior Task. Consider the following examples:

To pass in a static JSON map with static values, use the format shown below.

```
```
{  
  "my_key1": "my_value1",  
  "my_key2": "my_value2"  
}
```
```

To pass in a static JSON map with dynamic values seeded from prior Task results, ensure the RESULT TYPE value of one or more of the prior Tasks in the Workflow phase is set to “Single Value” and refer to the values within the JSON map as shown in the next example. Note that “taskCode1” and “taskCode2” refer to the CODE field value for the Task whose output you wish to reference.

```
```
{  
  "my_key1": "<%=results.taskCode1%>",  
  "my_key2": "<%=results.taskCode2%>"  
}
```
```

To pass in a dynamic JSON map returned from a prior Task, format your Write Attributes Task as shown in the next example. Ensure that the RESULT TYPE value for the Task returning a JSON map is set to “JSON”. Note that “taskCode” in the example refers to the CODE field value for the Task being referenced. In order for the JSON map to be set correctly and able to be referenced from future Tasks, you must set the “instances” key and call the `encodeAsJSON()` Groovy method as shown in the example.

```
```
{  
  "instances": <%=results.taskCode?.encodeAsJSON()%>  
}
```
```
