マルチステップフォーム
1 つのフォームから複数の playbook やテンプレートを順に実行する
multistepはバージョン 7 から非推奨で、8 で削除されます。代わりに ワークフロー を使ってください。ワークフローは、 マルチステップでできることをすべて行え、さらに条件、ノードごとの独自の値、承認ノード、並行して実行される分岐も使えます。
Deprecated since 7, removed in 8: use workflow. A workflow does all a multistep does - its nodes run on any runner (runner:), with a condition (if_extra_var, as ifExtraVar) and their own values (extra_vars_key, as key), with approval nodes - and runs branches side by side. Until 8 a multistep runs as it did, and the log says it is deprecated.
Executes multiple jobs sequentially.
Each step can be a different type (ansible, awx, semaphore, rundeck, jenkins …).
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
- name: vm_name
type: textフォームレベルのプロパティ
マルチステップフォームは、1 つのフォームレベルのプロパティでステップを定義します。
| 属性 | 説明 |
|---|---|
| steps array / 必須 | Multistep steps Deprecated since 7, removed in 8, with the multistep type: a workflow’s nodes do what steps do. |
steps のほかに、マルチステップフォームは次のフォームレベルのプロパティを受け付けます。これらは Ansible フォーム のページで説明しています。 roles (必須), categories, showHelp, icon, iconColor, iconSize, overlayIcon, overlayIconTransform, overlayIconColor, overlayIconCircle, overlayIconText, overlayIconTextPosition, overlayIconTextColor, image, tileClass, fieldGroupClasses, wizard, userExtravars, abortable, allowRelaunch, allowStoredJobSharing, launchValidation, enableForChat, order, approval, notifications, onSubmit, onSuccess, onFailure, onAbort, onFinish.
ステップのプロパティ
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, the awx-specific form properties apply to that step (e.g. template, job, awx, awxCredentials, inventory, check, diff, tags, approval, notifications, …), except executionEnvironment, instanceGroups and scm_branch: a step does not accept them.
| 属性 | 説明 |
|---|---|
| basic | |
| name string / 必須 | The name of the form
The name of the step. Used for logging and visualization. |
| type string | Step type
Every step runs an Ansible playbook ( 選択肢:
例: 1) Run AWX Template Helloworld 2) Run Ansible playbook |
| workflow | |
| key string | Extravar key
AnsibleForms can model the extravars into objects using the formfield 例: 1) Resize volume |
| ifExtraVar extravar reference | Run step if ...
In a mulitstep form, by default, AnsibleForms will try to run every step sequentially one after the other. 例: 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’. 既定値: false 例: 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. 既定値: false 例: 1) |
例
マルチステップフォームは複数のジョブを順に実行し、各ステップが独自の playbook または AWX テンプレートを起動します。すべてのステップはフォームのフィールドを共有します。既定では各ステップが extravars 全体を受け取り、ステップの key を指定するとその部分だけに限定されます。
サーバーを作成して設定する
各ステップは extravars のそれぞれの部分を受け取ります。AWX のステップがサーバーを作成し、Ansible のステップがそのネットワークを設定し、最後のステップが常にレポートを送信します。
name: Server Provisioning
type: multistep
roles:
- default
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