Automation

Provisioning -> Automation

The Automation section is composed of Tasks and Workflows. Tasks can be scripts added directly, scripts and blueprints from the Library section, recipes, playbooks, salt states, puppet agent installs, or http (api) calls. These Tasks are are combined into workflows, which can be selected to run at provision time or executed on existing instances via Actions -> Run Workflow.

Tasks

Overview

There are many Task Types available, including scripts added directly, scripts and templates from the Library section, recipes, playbooks, salt states, puppet agent installs, and http (api) calls. Tasks are primarily created for use in Workflows, but a single Task can be executed on an existing instance via Actions -> Run Task.

Role Permissions

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

Tasks Types that can execute locally against the Morpheus Appliance have an additional Role Permission: Tasks - Script Engines. Script Engine Task Types will be hidden for users without Tasks - Script Engines role permissions.

Task Types

Available Task Types
  Task Type Task Description Task Target Configuration Requirements Role Permissions Requirements
ansible Ansible Runs an Ansible playbook. Ansible Integration required Instance or Host Existing Ansible Integration Provisioning: Tasks
chef Chef bootstrap Executes Chef bootstrap and run list. Chef Integration required Instance or Host Existing Chef Integration Provisioning: Tasks
groovy Groovy script Executes Groovy Script locally (on Morpheus app node) Local None Provisioning: Tasks, Tasks - Script Engines
http HTTP Executes REST call for targeting external API’s. URL specified in Task None Provisioning: Tasks
javascript Javascript Executes Javascript locally (on Morpheus app node) Local None Provisioning: Tasks, Tasks - Script Engines
jruby jRuby Scirpt Executes Ruby script locally (on Morpheus app node) Local None Provisioning: Tasks, Tasks - Script Engines
libraryscript Library Script Creates a Task from an existing Library Script (Provisioning -> Library -> Scripts) Instance or Host Existing Library Script Provisioning: Tasks
template Library Template Creates a Task from an existing Library Template (Provisioning -> Library-> Templates) Instance or Host Existing Library Templates Provisioning: Tasks
localscript Local Shell Script Executes Bash script locally (on Morpheus app node) Local None Provisioning: Tasks, Tasks - Script Engines
puppet Puppet Agent Install Executes Puppet Agent bootstrap, writes puppet.conf and triggers agent checkin. Puppet Integration required Instance or Host Existing Puppet Integration Provisioning: Tasks
jython Python Script (jython) Executes Python script locally (on Morpheus app node) Local None Provisioning: Tasks, Tasks - Script Engines
shellscript Remote Shell Script Executes Bash script against the Instance or Host the Task or Workflow is ran on Instance or Host None Provisioning: Tasks
restart Restart Restarts target VM/Host/Container and confirms status before executing next task in Workflow Instance or Host None Provisioning: Tasks
ssh SSH Script Execute Bash script against IP specified in Task. IP specified in Task None Provisioning: Tasks
winrm WinRM Script Execute Powershell script against IP specified in Task. IP specified in Task None Provisioning: Tasks

ansible Ansible Playbook

Description:

Runs an Ansible playbook. Ansible Integration required

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

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 Ref’s 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.

chef Chef Bootstrap

Description:

Executes Chef bootstrap and run list. Chef Integration required

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

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 uon 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 {}

groovy Groovy script

Description:

Executes Groovy Script locally (on app node)

Target:

Local App Node

Role Permissions:
 

Provisioning: Tasks Provisioning: Tasks - Script Engines

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Contents of Groovy Script to execute

http HTTP (api)

Description:

Executes REST call for targeting external API’s.

Target:

URL specified in Task

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
URL

http or https url for 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
Http Header examples
Authorization Bearer token
Content-Type application/json

javascript Javascript

Description:

Executes Javascript locally (on app node)

Target:

Local App Node

Role Permissions:
 

Provisioning: Tasks Provisioning: Tasks - Script Engines

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Contents of Javascript to execute

jruby jRuby Script

Description:

Executes Ruby script locally (on app node)

Target:

Local App Node

Role Permissions:
 

Provisioning: Tasks Provisioning: Tasks - Script Engines

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Contents of jRuby Script to execute

libraryscript Library Script

Description:

Creates a Task for an existing Library Script (Provisioning -> Library -> Scripts)

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Search for and select existing Library Script

template Library Template

Description:

Creates a Task for an existing Library Template (Provisioning -> Library-> Templates)

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

TEMPLATE

Search for and select existing Library Template

localscript Local Shell Script

Description:

Executes Bash script locally (on Morpheus app node)

Target:

Local App Node

Role Permissions:
 

Provisioning: Tasks Provisioning: Tasks - Script Engines

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
GIT REPO

Select a Git Repo which can be referenced in the Script.

GIT REF

Specify git ref such as branch

SCRIPT

Bash Script to execute. If a Git Repo is specified, files in the repo can be called in the script.

puppet Puppet Agent Install

Description:

Executes Puppet Agent bootstrap, writes puppet.conf and triggers agent checkin. Puppet Integration required

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

PUPPET MASTER

Select Puppet Master from existing Puppet Integration

PUPPET NODE NAME

Enter Puppet Node Name. Variables supported eg. "<%= instance.name %>"

PUPPET ENVIRONMENT

Enter Puppet Env. eg. production

jython Python Script (jython)

Description:

Executes Python script locally (on app node)

Target:

Local App Node

Role Permissions:
 

Provisioning: Tasks Provisioning: Tasks - Script Engines

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

TYPE

Python Script (jython)

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Python Script (jython) Script to execute

shellscript Remote Shell Script

Description:

Executes Bash script against the Instance or Host the Task or Workflow is ran on

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
SCRIPT

Enter Bash Script to execute

restart Restart

Description:

Specifically for use in Workflows after a task that requires a restart, the Restart task executes a restart on the target Instance or Host. Morpheus will wait until the restart is complete to execute the next task in the workflow phase.

Target:

Instance or Host

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

ssh SSH Script

Description:

Execute Bash script against IP specified in Task.

Target:

IP specified in Task

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
IP ADDRESS

IP Address of the ssh task target

PORT

SSH port for ssh task target (22 default)

KEY

Select existing Keypair for key auth

USERNAME

Username for ssh task target

PASSWORD

Password for ssh task target

SCRIPT

Enter Bash Script to execute

WinRM Script

winrm

Description:

Execute Powershell script against IP specified in Task.

Target:

IP specified in Task

Role Permissions:
 

Provisioning: Tasks

Task Configuration:
 
NAME

Name of the Task

CODE

Unique code name for api, cli, and variable reference

RESULT TYPE
  • Single Value
  • Key/Value Pairs
  • JSON
IP ADDRESS

IP Address of the WinRM task target

PORT

SSH port for WinRM task target (5985 default)

USERNAME

Username for WinRM task target

PASSWORD

Password for WinRM task target

SCRIPT

Enter Script to execute

Task Management

Adding Tasks

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Add button.
  4. From the New Task Wizard input a name for the task.
  5. Select the type of task from from the type dropdown.
  6. Input the appropriate details dependent on the task type you selected from the dropdown.
  7. Save

Editing Tasks

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Edit icon on the row of the task you wish to edit.
  4. Modify information as needed.
  5. Click the Save Changes button to save.

Deleting Tasks

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Delete icon on the row of the task you wish to delete.

Task Results

Overview

Task Results allow Tasks to use the output from preceding Tasks in the same Workflow via results variables.

Configure Tasks

In script type tasks, if RESULT TYPE is set, Morpheus will store the Task’s output as a variable.

Results Types

  • Single Value
    Entire task output is stored in <%=results.taskCode%> or <%=results["Task Name"]%> variable.
  • Key/Value pairs
    Expects key=value,key=value output. Entire task output is available with <%=results.taskCode%> or <%=results["Task Name"]%> variable (output inside []). Individual Values are avilable with <%=results.taskCode.key%> variables.
  • JSON
    Expects key:value,key:value json formatted output. Entire task output is available with <%=results.taskCode%> or <%=results["Task Name"]%> variable (output inside []). Individual Values are avilable with <%=results.taskCode.key%> variables.

Important

The entire output of a script is treated as results, not just the last line. Ensure formatting is correct for the appropriate result type. For example, if Results Type is json and the output is not fully json compatible, the result would not return properly.

Examples

Single Value using Task Code:
 
Source Task Config
NAME

Var Code (single)

CODE

single

RESULT TYPE

Single Value

SCRIPT

echo "string value"

Source Task Output

string value

Results Task using task code in variable
Results Task Script

echo "single: <%=results.single%>"

Results Task Output

single: string value

Single Value using Task Name:
 
Source Task Config
NAME

Var Code

CODE

none

RESULT TYPE

Single Value

SCRIPT

echo "string value"

Source Task Output

string value

Results Task using task name in variable
Results Task Script

echo "task name: <%=results["Var Code"]%>"

Results Task Output

task name: test value

Key/Value Pairs:
 
Source Task Config
NAME

Var Code (keyval)

CODE

keyval

RESULT TYPE

Key/Value pairs

SCRIPT

echo "flash=bang,ping=pong"

Source Task Output

flash=bang,ping=pong

Results Task for all results
Results Task Script

echo "keyval: <%=results.keyval%>"

Results Task Output

keyval: [flash:bang, ping:pong]

Results Task for a single value)
Results Task Script

echo "keyval value: <%=results.keyval.flash%>"

Results Task Output

keyval value: bang

JSON:
Source Task Config
NAME

Var Code (json)

CODE

json

RESULT TYPE

JSON

SCRIPT

echo "{\"ping\":\"pong\",\"flash\":\"bang\"}"

Source Task Output

{"ping":"pong","flash":"bang"}

Results Task for all results
Results Task Script

echo "json: <%=results.json%>"

Results Task Output

json: [ping:pong, flash:bang]

Results Task for a single value
Results Task Script

echo "json value: <%=results.json.ping%>"

Results Task Output

json value: pong

Python:

Python tasks can access the results dictionary directly:results[key]. To pass the results of a Python task to the next task within a workflow add the results as a value within the results dictionary. For example results['taskcode'] = 'Hello World' where ‘taskcode’ is the code of the task.

Results are available for all tasks executed in a workflow. For example, instead of using just one Tasks results in another Task, we can use all of the Task Results from the tasks above in a single task inside a workflow. :Multiple Task Results:

Results Task Script
echo "single: <%=results.single%>"
echo "task name: <%=results["Var Code"]%>"
echo "keyval: <%=results.keyval%>"
echo "keyval value: <%=results.keyval.flash%>"
echo "json: <%=results.json%>"
echo "json value: <%=results.json.ping%>"
Results Task Output
single: string value
task name: string value
keyval: [flash:bang, ping:pong
]
keyval value: bang
json: [ping:pong, flash:bang]
json value: pong

Workflows

Add Workflow

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Workflows tab to show the Workflows tab panel.
  4. Click the Add button.
  5. From the New Workflow Wizard input a name for the workflow.
  6. Optionally input a description.
  7. Expand the execution phases to add tasks to, and type the name of a created task and click the task when it appears to add.
  8. If multiple tasks are added to the same execution phase, their execution order can be changed by selecting the grip icon and dragging the task to the desired execution order.
  9. For multi-tenant environments, select Public or Private visibility for the Workflow.
  10. Click the Save Changes button to save.

Workflow Execution Phases

For VM’s, Pre-Provision and Provision execute after the VM is running. Pre-Provision can be used for a blueprint so it is added before a script set at the Provision phase executes. Pre-Provision for scripts is mainly for Docker as you can execute on the host before the container is up. Post-Provision will execute after the entire provisioning process is complete.

Edit Workflow

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Workflows tab to show the workflows tab panel.
  4. Click the Edit icon on the row of the workflow you wish to edit.
  5. Modify information as needed.
  6. Click the Save Changes button to save.

Delete Workflow

  1. Select the Provisioning link in the navigation bar.
  2. Select Automation from the sub-navigation menu.
  3. Click the Workflows tab to show the workflows tab panel.
  4. Click the Delete icon on the row of the workflow you wish to delete.