Functionality - Variables

Using Variables

Summary

A variable created using save or set can be used in different ways.

You may want to:

  • Display its value to the Task Operator

  • Display the result of an expression that uses its value

  • Make a decision based on its value

  • Use it as a built-in or plugin action parameter

Each use listed above is either elaborated on or linked to below.

Displaying Values

Simple Formatting

  • Wrap a variable name in {{ }} to display its value inside some text
Simple Formatting
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  actions:
    - ppa.ui.input_choice:
        text: Please Choose a Team
        options:
          - Engineering
          - Sales
          - Marketing
      save: team

    - ppa.ui.output_info:
        text: You chose the {{ team }} team

Expression Formatting

Use Jinja2 expressions to display different text based on a variable's value.

This example displays yes or no depending on the value of the boolean variable choice.

Read more about Jinja2 expressions in the jinja documentation.

Expression Formatting
1
2
3
4
5
6
7
8
9
  actions:
    - ppa.ui.input_confirm:
        text: Please Choose an Option
        confirm: Yes
        cancel: No
      save: choice

    - ppa.ui.output_info:
        text: You chose {{ 'yes' if choice else 'no' }}

Supplying to Actions

Use load to supply variables as action parameters.

This example supplies the group_memberships variable as the group_list action parameter.

Loading a Group List
1
2
3
4
- active_directory.groups.output_table:
    text: User Group Memberships
  load:
    group_list: group_memberships 

Making Decisions

See the conditionals page for information & examples.