Workaround for Accessing config_context in a Mistral Workflow

howto
mistral

(Nick Maludy) #1

Reference

Problem
Currently in a Mistral Workflow you can not access the config_context described here: Actions — StackStorm 2.7.1 documentation

StackStorm currently doesn’t pass this context into Mistral or provide a Jinja filter to access it.

Workaround
To access the config context information in a Mistral workflow, you can simply create a new parameter in the StackStorm action metadata. This new paramter can be immutable parameter and set with default that reads from the config context.

Example :

Action metadata file

parameters:
    config_username:
        type: "string"
        description: "Username from the pack's config"
        required: true
        immutable: true
        default: "{{ config_context.username }}"

Finally, add this new parameter as an input in your Mistral workflow, then you can access it like a normal Mistral variable.

examples.config_context_example:
  description: 
  type: direct
  input:
    - config_username

  tasks:
    action: core.local
    input:
      cmd: "echo {{ _.config_username }}"