Multistep forms
Run several playbooks or templates in sequence from one form
Executes multiple jobs sequentially.
Each step can be a different type (ansible, awx).
Multistep form
- name: Create VM
roles: # reference to roles defined earlier
- vmware
description: Create and start a vm
image: https://picsum.photos/64 # an image url (can be base64)
categories: # reference to categories defined earlier
- Demo
- Vmware
tileClass: bg-danger # a bootstrap background color style (https://getbootstrap.com/)
type: multistep # type is awx, ansible or multistep
steps:
- type: awx
name: Create vm
template: Create VM
key: vmInfo
- type: awx
name: Start vm
template: Start VM
key: vmInfo
- type: ansible
name: Email results
playbook: email.yaml
always: true # always run this task, even if others failed
fieldGroupClasses: # give fieldgroups a custom background
groupname1: bg-info-subtle
groupname2: bg-success-subtle
fields: # list of field objects Form-level property
A multistep form defines its steps in a single form-level property:
| Attribute | Comments |
|---|---|
| steps array / required | Multistep steps A multistep form is basically an array of multiple form type destinations, defined here as steps. |
Besides steps, a multistep form accepts these form-level properties, documented on the Ansible forms page: roles (required), categories, showHelp, icon, iconColor, iconSize, overlayIcon, overlayIconTransform, overlayIconColor, overlayIconCircle, overlayIconText, overlayIconTextPosition, overlayIconTextColor, image, tileClass, fieldGroupClasses, wizard, userExtravars, abortable, allowRelaunch, launchValidation, enableForChat, order, approval, notifications, onSubmit, onSuccess, onFailure, onAbort, onFinish.
Step properties
Each step is a new form destination. And steps are executed sequentially.
Use specific properties like continue, always and ifExtraVar to control the flow of a multistep form.
When a step has type: ansible, all ansible-specific form properties apply to that step (e.g. playbook, playbookSubPath, ansibleCredentials, vaultCredentials, inventory, check, diff, tags, varsFiles, approval, notifications, …).
When a step has type: awx, all awx-specific form properties apply to that step (e.g. template, awx, awxCredentials, executionEnvironment, instanceGroups, scmBranch, inventory, check, diff, tags, approval, notifications, …).
| Attribute | Comments |
|---|---|
| basic | |
| name string / required | The name of the form
The name of the step. Used for logging and visualization. |
| type string | Step type
Every step can be an ansible-playbook or an awx-template Choices:
Examples: 1) Run AWX Template Helloworld 2) Run Ansible playbook |
| workflow | |
| key string | Extravar key
Ansible Forms can model the extravars into objects using the formfield Examples: 1) Resize volume |
| ifExtraVar extravar reference | Run step if ...
In a mulitstep form, by default, Ansible Forms will try to run every step sequentially one after the other. Examples: 1) Run step based on checkbox |
| continue boolean | Continue on fail
In a mulitstep form, by default, if 1 step fails, the multistep is stopped. However, if you want to continue to the next step, even if the current step failed, use this attribute and set it to true and the multistep will goto the next step. If this happens the status becomes ‘partially success’. Default: false Examples: 1) |
| always boolean | Always run
In a mulitstep form, by default, if 1 step fails, the multistep is stopped. However, if you always want to run a certain step, even if a step failed somewhere, use this attribute and set it to true and the specific step will always run. Default: false Examples: 1) |
Example
A multistep form runs several jobs in sequence, each step launching its own playbook or AWX template. All steps share the fields of the form: by default, every step receives the full extravars, and a step’s key restricts it to that part of them.
Create and configure a server
Each step receives its own part of the extravars: an AWX step creates the server, an Ansible step configures its network, and a final step always sends a report:
name: Server Provisioning
type: multistep
roles:
- public
categories:
- Setup
steps:
- name: Create server
type: awx
template: Create VM
key: server # receives only the `server` part of the extravars
- name: Configure network
type: ansible
playbook: configure_network.yml
key: network # receives only the `network` part of the extravars
- name: Send report
type: ansible
playbook: email.yml
always: true # runs even when an earlier step failed
fields:
- name: server_name
type: text
model: server.name
- name: environment
type: enum
values:
- dev
- prod
model: server.environment
- name: ip_address
type: text
model: network.ip
- name: gateway
type: text
model: network.gateway