Skip to content

Context

The context is the data that a workflow execution carries through its steps. It contains entity information (devices, interfaces, groups), workflow parameters, and results from previous steps. Every JMESPath expression in your workflow resolves against this context.

What's in the Context

Context path What it contains
parameters User-provided values at execution time.
context.device Seed device data (hostname, IP, facts, ...).
context.interfaces Interfaces list for the seed device (when applicable).
context.device_groups Groups list associated with the device.
<step_label>.result Result payloads from previous steps.

Static context (available from the start)

  • parameters -- Values passed when the workflow execution was triggered (e.g., timeout, backup_type)
  • context.device / context.interface / context.device_group -- The seed entity data loaded from the CMS

Dynamic context (populated during execution)

  • <step_label>.result -- The result data from a completed step. For example, if a step labeled ping returns { "reachable": true }, subsequent steps can access {{ ping.result.data.reachable }}
  • Acquired entities -- Additional entities pulled in through acquire clauses

How Context Gets Populated

Phase Actor Action Context impact
Execution trigger User Starts a workflow with deviceIds and parameters parameters populated
Entity acquisition Engine → CMS Locks and fetches entities context.* seed data populated
Step-level acquire Engine → Worker Runs ACQUIRE jobs Adds acquired entities to context.*
Step execution Engine → Worker Runs EXECUTE jobs Adds <step_label>.result
  1. Execution trigger -- The user provides entity IDs or queries and workflow parameters
  2. Entity acquisition -- The engine requests entities from the CMS and locks them
  3. Step-level acquire -- If steps define acquire clauses, the engine runs ACQUIRE jobs to gather additional data
  4. Execution -- Each step receives the accumulated context and its result is added to the context for subsequent steps

JMESPath Expressions

Parameters, conditions, and assertions use {{ expression }} syntax. The expression is a JMESPath query evaluated against the context.

New to JMESPath?

JMESPath is a query language for JSON, similar to XPath for XML. If you have used jq or Python dictionary access like device["facts"]["version"], JMESPath works similarly: context.device.facts.version. The JMESPath tutorial is a quick 5-minute read.

Accessing entity data

parameters:
  host: "{{ context.device.ip }}"
  hostname: "{{ context.device.hostname }}"
  platform: "{{ context.device.platform.shortName }}"

Accessing workflow parameters

parameters:
  timeout: "{{ parameters.timeout }}"
  mode: "{{ parameters.backup_mode }}"

Accessing previous step results

# If a step labeled 'ping' returned { data: { reachable: true, latency: 5 } }
condition:
  type: jmes
  jmes: "{{ ping.result.data.reachable == true }}"

parameters:
  latency: "{{ ping.result.data.latency }}"

Raw parameters (no interpolation)

Use rawParameters when you need literal curly braces or JMESPath expressions as values (not evaluated):

parameters:
  query: "{{ context.device.hostname }}"    # interpolated
rawParameters:
  template: "hostname {{ hostname }}"        # literal string, not interpolated

rawParameters and parameters are merged, with rawParameters taking precedence for duplicate keys.


See also: