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¶
Task Type | Task Description | Task Target | Configuration Requirements | Role Permissions Requirements | |
---|---|---|---|---|---|
![]() |
Ansible | Runs an Ansible playbook. Ansible Integration required | Instance or Host | Existing Ansible Integration | Provisioning: Tasks |
![]() |
Chef bootstrap | Executes Chef bootstrap and run list. Chef Integration required | Instance or Host | Existing Chef Integration | Provisioning: Tasks |
![]() |
Groovy script | Executes Groovy Script locally (on Morpheus app node) | Local | None | Provisioning: Tasks, Tasks - Script Engines |
![]() |
HTTP | Executes REST call for targeting external API’s. | URL specified in Task | None | Provisioning: Tasks |
![]() |
Javascript | Executes Javascript locally (on Morpheus app node) | Local | None | Provisioning: Tasks, Tasks - Script Engines |
![]() |
jRuby Scirpt | Executes Ruby script locally (on Morpheus app node) | Local | None | Provisioning: Tasks, Tasks - Script Engines |
![]() |
Library Script | Creates a Task from an existing Library Script (Provisioning -> Library -> Scripts ) |
Instance or Host | Existing Library Script | Provisioning: Tasks |
![]() |
Library Template | Creates a Task from an existing Library Template (Provisioning -> Library-> Templates ) |
Instance or Host | Existing Library Templates | Provisioning: Tasks |
![]() |
Local Shell Script | Executes Bash script locally (on Morpheus app node) | Local | None | Provisioning: Tasks, Tasks - Script Engines |
![]() |
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 |
![]() |
Python Script (jython) | Executes Python script locally (on Morpheus app node) | Local | None | Provisioning: Tasks, Tasks - Script Engines |
![]() |
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 | Restarts target VM/Host/Container and confirms status before executing next task in Workflow | Instance or Host | None | Provisioning: Tasks |
![]() |
SSH Script | Execute Bash script against IP specified in Task. | IP specified in Task | None | Provisioning: Tasks |
![]() |
WinRM Script | Execute Powershell script against IP specified in Task. | IP specified in Task | None | Provisioning: Tasks |
Ansible Playbook¶
Description: | Runs an Ansible playbook. Ansible Integration required |
---|---|
Target: | Instance or Host |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
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 Bootstrap¶
Description: | Executes Chef bootstrap and run list. Chef Integration required |
---|---|
Target: | Instance or Host |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
Groovy script¶
Description: | Executes Groovy Script locally (on app node) |
---|---|
Target: | Local App Node |
Role Permissions: | |
Provisioning: Tasks Provisioning: Tasks - Script Engines |
|
Task Configuration: | |
|
HTTP (api)¶
Description: | Executes REST call for targeting external API’s. |
||||
---|---|---|---|---|---|
Target: | URL specified in Task |
||||
Role Permissions: | |||||
Provisioning: Tasks |
|||||
Task Configuration: | |||||
|
Javascript¶
Description: | Executes Javascript locally (on app node) |
---|---|
Target: | Local App Node |
Role Permissions: | |
Provisioning: Tasks Provisioning: Tasks - Script Engines |
|
Task Configuration: | |
|
jRuby Script¶
Description: | Executes Ruby script locally (on app node) |
---|---|
Target: | Local App Node |
Role Permissions: | |
Provisioning: Tasks Provisioning: Tasks - Script Engines |
|
Task Configuration: | |
|
Library Script¶
Description: | Creates a Task for an existing Library Script ( |
---|---|
Target: | Instance or Host |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
Library Template¶
Description: | Creates a Task for an existing Library Template ( |
---|---|
Target: | Instance or Host |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
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: | |
|
Puppet Agent Install¶
Description: | Executes Puppet Agent bootstrap, writes |
---|---|
Target: | Instance or Host |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
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: | |
|
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: | |
|
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: | |
|
SSH Script¶
Description: | Execute Bash script against IP specified in Task. |
---|---|
Target: | IP specified in Task |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
WinRM Script¶
Description: | Execute Powershell script against IP specified in Task. |
---|---|
Target: | IP specified in Task |
Role Permissions: | |
Provisioning: Tasks |
|
Task Configuration: | |
|
Task Management¶
Adding Tasks¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- Click the Add button.
- From the New Task Wizard input a name for the task.
- Select the type of task from from the type dropdown.
- Input the appropriate details dependent on the task type you selected from the dropdown.
- Save
Editing Tasks¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- Click the Edit icon on the row of the task you wish to edit.
- Modify information as needed.
- Click the Save Changes button to save.
Deleting Tasks¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- 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 phase via results variables.
Results are available for all tasks executed in the same phase 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 in the same provision phase in a single task inside a workflow.
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.
Important
Task results are not supported for Library Script task types
Script Config Examples¶
Single Value using Task Code: | |||||
---|---|---|---|---|---|
|
|||||
Single Value using Task Name: | |||||
|
|||||
Key/Value Pairs: | |||||
|
|||||
JSON: |
|
Workflow Config¶
Add one or multiple tasks with Results Type configured to a workflow, and the results will be available to all tasks in the same phase of the workflow via the <%=results.variables%>
during the workflow execution.
- Task Results are only available to tasks in the same workflow phase
- Task Results are only available during workflow execution
Workflows¶
Add Workflow¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- Click the Workflows tab to show the Workflows tab panel.
- Click the Add button.
- From the New Workflow Wizard input a name for the workflow.
- Optionally input a description.
- 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.
- 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.
- For multi-tenant environments, select Public or Private visibility for the Workflow.
- 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¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- Click the Workflows tab to show the workflows tab panel.
- Click the Edit icon on the row of the workflow you wish to edit.
- Modify information as needed.
- Click the Save Changes button to save.
Delete Workflow¶
- Select the Provisioning link in the navigation bar.
- Select Automation from the sub-navigation menu.
- Click the Workflows tab to show the workflows tab panel.
- Click the Delete icon on the row of the workflow you wish to delete.
Variables¶
The following are the map structures passed to scripts and templates during provisioning inside of a <%= %>
block.
Variables can also be passed in Naming Policies using ${ }
block.
Important
Variables are case sensitive
PowerShell Example: $app_id = "<%= instance.metadata.app_id %>"
Bash Example: HOSTNAME="<%= container.server.hostname %>"
Python Example: hostname = container['server']['hostname']
HTTP Body Example: {"name": "<%= instance.createdByUsername %>"}
Instance Naming Policy example: ${userInitials}-${cloudCode}-${platform == 'windows' ? 'W' : 'L'}-${sequence}
Tip
Variables can be extremely useful when utilized in the environment tab, metadata, and environment variables.
Note
customOptions values are defined from custom Option Types.
container.configGroup: <%=container.configGroup%>
container.configId: <%=container.configId%>
container.configPath: <%=container.configPath%>
container.configRole: <%=container.configRole%>
container.containerTypeCode: <%=container.containerTypeCode%>
container.containerTypeName: <%=container.containerTypeName%>
container.containerTypeShortName: <%=container.containerTypeShortName%>
container.cores: <%=container.cores%>
container.dataPath: <%=container.dataPath%>
container.dateCreated: <%=container.dateCreated%>
container.domainName: <%=container.domainName%>
container.environmentPrefix: <%=container.environmentPrefix%>
container.externalIp: <%=container.externalIp%>
container.hostMountPoint: <%=container.hostMountPoint%>
container.hostname: <%=container.hostname%>
container.image: <%=container.image%>
container.internalHostname: <%=container.internalHostname%>
container.internalIp: <%=container.internalIp%>
container.logsPath: <%=container.logsPath%>
container.memory: <%=container.memory%>
container.planCode: <%=container.planCode%>
container.provisionType: <%=container.provisionType%>
container.server: <%=container.server.serverTypeName%>
container.serverId: <%=container.serverId%>
container.sshHost: <%=container.sshHost%>
container.status: <%=container.status%>
container.storage: <%=container.storage%>
container.version: <%=container.version%>
customOptions: <%=customOptions.fieldName%>
evar: <%=evars.name%>
evars: <%=evars%>
group.code: <%=group.code%>
group.datacenterId: <%=group.datacenterId%>
group.location: <%=group.location%>
group.name: <%=group.name%>
instance.autoScale: <%=instance.autoScale%>
instance.configGroup: <%=instance.configGroup%>
instance.configId: <%=instance.configId%>
instance.configRole: <%=instance.configRole%>
instance.containers[0]: <%=instance.containers[0].containerTypeName%>
instance.cores: <%=instance.cores%>
instance.createdByEmail: <%=instance.createdByEmail%>
instance.createdByFirstName: <%=instance.createdByFirstName%>
instance.createdById: <%=instance.createdById%>
instance.createdByLastName: <%=instance.createdByLastName%>
instance.createdBYUsername: <%=instance.createdByUsername%>
instance.deployGroup: <%=instance.deployGroup%>
instance.description: <%=instance.description%>
instance.displayName: <%=instance.displayName%>
instance.domainName: <%=instance.domainName%>
instance.environmentPrefix: <%=instance.environmentPrefix%>
instance.expireDate: <%=instance.expireDate%>
instance.firewallEnabled: <%=instance.firewallEnabled%>
instance.hostname: <%=instance.hostname%>
instance.id: <%=instance.id%>
instance.instanceContext: <%=instance.instanceContext%>
instance.instanceLevel: <%=instance.instanceLevel%>
instance.instanceTypeCode: <%=instance.instanceTypeCode%>
instance.instanceTypeName: <%=instance.instanceTypeName%>
instance.instanceVersion: <%=instance.instanceVersion%>
instance.memory: <%=instance.memory%>
instance.metadata: <%=instance.metadata%>
instance.name: <%=instance.name%>
instance.networkLevel: <%=instance.networkLevel%>
instance.plan: <%=instance.plan%>
instance.provisionType: <%=instance.provisionType%>
instance.status: <%=instance.status%>
instance.statusMessage: <%=instance.statusMessage%>
instance.storage: <%=instance.storage%>
instance.tags: <%=instance.tags%>
instance.userStatus: <%=instance.userStatus%>
server.agentInstalled: <%=server.agentInstalled%>
server.agentVersion: <%=server.agentVersion%>
server.apiKey: <%=server.apiKey%>
server.category: <%=server.category%>
server.commType: <%=server.commType%>
server.configGroup: <%=server.configGroup%>
server.configId: <%=server.configId%>
server.configRole: <%=server.configRole%>
server.consoleHost: <%=server.consoleHost%>
server.consolePort: <%=server.consolePort%>
server.consoleType: <%=server.consoleType%>
server.consoleUsername: <%=server.consoleUsername%>
server.dataDevice: <%=server.dataDevice%>
server.dateCreated: <%=server.dateCreated%>
server.description: <%=server.description%>
server.displayName: <%=server.displayName%>
server.domainName: <%=server.domainName%>
server.externalId: <%=server.externalId%>
server.externalIp: <%=server.externalIp%>
server.fqdn: <%=server.fqdn%>
server.hostname: <%=server.hostname%>
server.internalId: <%=server.internalId%>
server.internalIp: <%=server.internalIp%>
server.internalName: <%=server.internalName%>
server.internalSshUsername: <%=server.internalSshUsername%>
server.lastAgentUpdate: <%=server.lastAgentUpdate%>
server.lvmEnabled: <%=server.lvmEnabled%>
server.macAddress: <%=server.macAddress%>
server.managed: <%=server.managed%>
server.maxCores: <%=server.maxCores%>
server.maxMemory: <%=server.maxMemory%>
server.maxStorage: <%=server.maxStorage%>
server.name: <%=server.name%>
server.nodePackageVersion: <%=server.nodePackageVersion%>
server.osDevice: <%=server.osDevice%>
server.osType: <%=server.osType%>
server.osTypeCode: <%=server.osTypeCode%>
server.parentServerId: <%=server.parentServerId%>
server.plan: <%=server.plan%>
server.platform: <%=server.platform%>
server.platformVersion: <%=server.platformVersion%>
server.powerState: <%=server.powerState%>
server.serialNumber: <%=server.serialNumber%>
server.serverModel: <%=server.serverModel%>
server.serverType: <%=server.serverType%>
server.serverTypeCode: <%=server.serverTypeCode%>
server.serverTypeName: <%=server.serverTypeName%>
server.serverVendor: <%=server.serverVendor%>
server.softwareRaid: <%=server.softwareRaid%>
server.sourceImageId: <%=server.sourceImageId%>
server.sshHost: <%=server.sshHost%>
server.sshPort: <%=server.sshPort%>
server.sshUsername: <%=server.sshUsername%>
server.status: <%=server.status%>
server.statusMessage: <%=server.statusMessage%>
server.tags: <%=server.tags%>
server.toolsInstalled: <%=server.toolsInstalled%>
server.visibility: <%=server.visibility%>
task.results (using task code): <%=results.taskCode%>
task.results (using task name): <%=results["Task Name"]%>
task.results.value: <%=results.taskCode.key%>
zone.agentMode: <%=zone.agentMode%>
zone.cloudTypeCode: <%=zone.cloudTypeCode%>
zone.cloudTypeName: <%=zone.cloudTypeName%>
zone.code: <%=zone.code%>
zone.domainName: <%=zone.domainName%>
zone.firewallEnabled: <%=zone.firewallEnabled%>
zone.location: <%=zone.location%>
zone.name: <%=zone.name%>
zone.regionCode: <%=zone.regionCode%>
zone.scalePriority: <%=zone.scalePriority%>
cypher: <%=cypher.read('secret/hello')%>
instance {
autoScale,
configGroup,
configId,
configRole
containers:[],
cores,
deployGroup,
description,
displayName,
domainName,
environmentPrefix,
evars:[],
expireDate,
firewallEnabled,
hostname,
instanceContext,
instanceLevel,
instanceTypeCode,
instanceVersion,
memory,
metadata:[],
name,
networkLevel,
plan,
provisionType,
status,
statusMessage,
storage,
tags,
tenantSubdomain,
userStatus,
instanceTypeName
}
.. code-block:: bash
container {
configGroup,
configId,
configPath,
configRole,
containerTypeCode,
containerTypeShortName,
cores,
dataPath,
dateCreated,
domainName,
environmentPrefix,
externalIp,
hostMountPoint,
hostname,
image,
internalHostname,
internalIp,
logsPath,
memory,
planCode,
provisionType,
server:{},
serverId,
sshHost,
status,
storage,
version,
containerTypeName
}
server {
agentInstalled,
agentVersion,
apiKey,
category,
commType,
configGroup,
configId,
configRole
consoleHost,
consolePort,
consoleType,
consoleUsername,
dataDevice,
dateCreated,
description,
displayName,
domainName,
externalId,
externalIp,
fqdn,
hostname,
internalId,
internalIp,
internalName,
internalSshUsername,
lastAgentUpdate,
lvmEnabled,
macAddress,
managed,
maxCores,
maxMemory,
maxStorage,
name,
nodePackageVersion,
osDevice,
osType,
osTypeCode,
parentServerId,
plan,
platform,
platformVersion,
powerState,
serialNumber,
serverModel,
serverType,
serverTypeCode,
serverTypeName,
serverVendor,
softwareRaid,
sourceImageId,
sshHost,
sshPort,
sshUsername,
status,
statusMessage,
tags,
toolsInstalled,
visibility,
volumes {
name
id
deviceName
maxStorage
unitNumber
displayOrder
rootVolume
}
}
zone {
agentMode,
cloudTypeCode,
cloudTypeName,
code,
datacenterId,
domainName,
firewallEnabled,
location,
name,
regionCode,
scalePriority
}
group {
code,
location,
datacenterId,
name
}
customOptions {
customOptions.fieldName
}