var
Sets or appends a variable in the workflow context for use in subsequent steps
Options
| Name | Type | Description |
|---|---|---|
var | string | The name of the variable to set in the workflow context |
value | any | The value to assign (or append) to the variable |
append | bool | When true, appends Value to the existing variable instead of replacing it |
append_source | any | The existing variable object to read from when appending |
Examples
name: Total an invoice list
actions:
- name: invoices
component: app:records:query
vars:
org_id: "{{ var.org_id }}"
schema: billing
table: invoices
- name: total
component: var
vars:
var: total
value: "{{ invoices.items | pluck:'amount' | sum }}"
outputs:
total: "{{ total.total }}"Append
Grows a list one value at a time. append: true pushes the
rendered value onto append_source, which is how a loop accumulates results
across iterations.
name: Collect failures across a loop
actions:
- name: check_each
component: each
vars:
items: "{{ var.urls }}"
actions:
- name: probe
component: http
vars:
url: "{{ check_each.output }}"
- name: failures
component: var
if: "{{ probe.code | gte:400 }}"
vars:
var: urls
value: "{{ check_each.output }}"
append: true
append_source: "{{ failures.urls | default:[] }}"
outputs:
failures: "{{ failures.urls }}"