define_context

Operation to context variables to the operation context.

Example

The following example adds a dictionary named template_variables with a single variable named name to the context:

examples/operations/define_context.yml
steps:
    "Define name to greet":
        name: define_context
        context_defs:
            template_variables:
                name: "World"
    "Display greeting":
        name: echo
        message: |
            Hello, {{ qwikstart.name }}!

To complete the example, the variable is used by the echo operation to display a simple hello-world greeting. Note that the template_variables dictionary, a.k.a. namespace, is used by default when rendering templates by the echo operation, and any other operations that render templates.

Required context

context_defs

Definition of variables to add to the context. Values can be defined using template variables; e.g.:

context_defs:
    greeting: "Hello {{ qwikstart.name }}!"

Optional context

template_variables

Dictionary of variables available when rendering the file template.

template_variable_prefix

default: 'qwikstart'

Template variables will be nested in this namespace when rendering; e.g: {{<template_variable_prefix>.your_template_variable}}

Output

This operation can define arbitrary output values based on context_defs.

Additional notes

Overrides default opconfig with:

  • display_description: False

See also